eeparams.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*********************************************************************
  2. *
  3. * Fraise eeprom stored parameters library
  4. *
  5. *********************************************************************
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *********************************************************************
  18. * Copyright (c) Antoine Rousseau nov 2011 - 2014
  19. ********************************************************************/
  20. #ifndef EEPARAMS_H
  21. #define EEPARAMS_H
  22. /** @file */
  23. #include "core.h"
  24. /** @defgroup eeparams EEPROM parameters module
  25. Save parameters values into EEPROM, and load them at setup.
  26. -------------
  27. example :
  28. ~~~~
  29. #include "fruit.h"
  30. int i;
  31. void setup() {
  32. EEreadMain(); // at boot time restore the value of "i" from EEPROM
  33. }
  34. void fraiseReceive() // if we received a "raw bytes" message
  35. {
  36. unsigned char c = fraiseGetChar(); // get the first byte of the message
  37. switch(c) {
  38. PARAM_INT(1,i); // if the first byte was 1 then set "i"
  39. EEwriteMain() ;// to the value of the next 16 bit integer and save EEPROM.
  40. break;
  41. }
  42. }
  43. void EEdeclareMain() {
  44. EEdeclareInt(&i); // declare "i" as an 16 bit integer into EEPROM storage.
  45. }
  46. ~~~~
  47. * @{
  48. */
  49. /** \name Read and write functions
  50. @{ */
  51. /** \brief Load all the parameters values from EEPROM ; you may call it at setup() */
  52. void EEreadMain();
  53. /** \brief Save all the parameters values to EEPROM */
  54. void EEwriteMain();
  55. /** @} */
  56. /** \name Parameters declaration functions
  57. @{ */
  58. /** \brief User may define this function, with a list of char/int/long declarations. */
  59. void EEdeclareMain();
  60. // EEdeclareMain() is definded with a sequence of :
  61. /** \brief Declare a 8 bit integer in EEdeclareMain().
  62. @param data Address of the parameter.*/
  63. void EEdeclareChar(unsigned char *data);
  64. /** \brief Declare a 16 bit integer in EEdeclareMain().
  65. @param data Address of the parameter.*/
  66. void EEdeclareInt(unsigned int *data);
  67. /** \brief Declare a 32 bit integer in EEdeclareMain().
  68. @param data Address of the parameter.*/
  69. void EEdeclareLong(unsigned long *data);
  70. /// @}
  71. /// @}
  72. #endif //EEPARAMS_H