main.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. Generated Main Source File
  3. Company:
  4. Microchip Technology Inc.
  5. File Name:
  6. main.c
  7. Summary:
  8. This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
  9. Description:
  10. This header file provides implementations for driver APIs for all modules selected in the GUI.
  11. Generation Information :
  12. Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7
  13. Device : PIC16LF18456
  14. Driver Version : 2.00
  15. */
  16. /*
  17. (c) 2018 Microchip Technology Inc. and its subsidiaries.
  18. Subject to your compliance with these terms, you may use Microchip software and any
  19. derivatives exclusively with Microchip products. It is your responsibility to comply with third party
  20. license terms applicable to your use of third party software (including open source software) that
  21. may accompany Microchip software.
  22. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
  23. EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
  24. IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
  25. FOR A PARTICULAR PURPOSE.
  26. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  27. INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
  28. WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
  29. HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
  30. THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
  31. CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
  32. OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
  33. SOFTWARE.
  34. */
  35. #include "mcc_generated_files/mcc.h"
  36. #include "serial.h"
  37. #include "rn4870/rn4870.h"
  38. #include "timekeeping.h"
  39. #include <stdio.h>
  40. extern void console_monitor(void);
  41. /*
  42. Main application
  43. */
  44. void main(void) {
  45. // initialize the device
  46. SYSTEM_Initialize();
  47. // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
  48. // Use the following macros to:
  49. // Enable the Global Interrupts
  50. INTERRUPT_GlobalInterruptEnable();
  51. // Enable the Peripheral Interrupts
  52. INTERRUPT_PeripheralInterruptEnable();
  53. serial_println("------ RN4870 - battery service ------\n");
  54. rn4870_init();
  55. init_timekeeping();
  56. #ifdef USE_HEARTBEAT
  57. uint16_t counter = 1;
  58. char msg[32];
  59. uint16_t t_heartbeat = millis();
  60. #endif
  61. while (1) {
  62. #ifdef USE_HEARTBEAT
  63. uint16_t t_now = millis();
  64. if (t_now - t_heartbeat >= 30000) {
  65. t_heartbeat = t_now;
  66. sprintf(msg, "heartbeat: %u", counter++);
  67. serial_println(msg);
  68. }
  69. #endif
  70. rn4870_monitor();
  71. console_monitor();
  72. // Add your application code
  73. }
  74. }
  75. /**
  76. End of File
  77. */