123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- Generated Main Source File
- Company:
- Microchip Technology Inc.
- File Name:
- main.c
- Summary:
- This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
- Description:
- This header file provides implementations for driver APIs for all modules selected in the GUI.
- Generation Information :
- Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7
- Device : PIC16LF18456
- Driver Version : 2.00
- */
- /*
- (c) 2018 Microchip Technology Inc. and its subsidiaries.
-
- Subject to your compliance with these terms, you may use Microchip software and any
- derivatives exclusively with Microchip products. It is your responsibility to comply with third party
- license terms applicable to your use of third party software (including open source software) that
- may accompany Microchip software.
-
- THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
- EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
- IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
- FOR A PARTICULAR PURPOSE.
-
- IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
- INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
- WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
- HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
- THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
- CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
- OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
- SOFTWARE.
- */
- #include "mcc_generated_files/mcc.h"
- #include "serial.h"
- #include "rn4870/rn4870.h"
- #include "timekeeping.h"
- #include <stdio.h>
- extern void console_monitor(void);
- /*
- Main application
- */
- void main(void) {
- // initialize the device
- SYSTEM_Initialize();
- // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
- // Use the following macros to:
- // Enable the Global Interrupts
- INTERRUPT_GlobalInterruptEnable();
- // Enable the Peripheral Interrupts
- INTERRUPT_PeripheralInterruptEnable();
- serial_println("------ RN4870 - battery service ------\n");
- rn4870_init();
- init_timekeeping();
- #ifdef USE_HEARTBEAT
- uint16_t counter = 1;
- char msg[32];
- uint16_t t_heartbeat = millis();
- #endif
- while (1) {
- #ifdef USE_HEARTBEAT
- uint16_t t_now = millis();
- if (t_now - t_heartbeat >= 30000) {
- t_heartbeat = t_now;
- sprintf(msg, "heartbeat: %u", counter++);
- serial_println(msg);
- }
- #endif
- rn4870_monitor();
- console_monitor();
- // Add your application code
- }
- }
- /**
- End of File
- */
|