Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TINYNVM.h 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. *
  28. * Header file for TINYNVM.c.
  29. */
  30. #ifndef _TINY_NVM_
  31. #define _TINY_NVM_
  32. /* Includes: */
  33. #include <avr/io.h>
  34. #include <avr/interrupt.h>
  35. #include <stdbool.h>
  36. #include <LUFA/Common/Common.h>
  37. #include "XPROGProtocol.h"
  38. #include "XPROGTarget.h"
  39. #include "Config/AppConfig.h"
  40. /* Preprocessor Checks: */
  41. #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
  42. #undef ENABLE_ISP_PROTOCOL
  43. #if !defined(ENABLE_XPROG_PROTOCOL)
  44. #define ENABLE_XPROG_PROTOCOL
  45. #endif
  46. #endif
  47. /* Defines: */
  48. #define TINY_NVM_CMD_NOOP 0x00
  49. #define TINY_NVM_CMD_CHIPERASE 0x10
  50. #define TINY_NVM_CMD_SECTIONERASE 0x14
  51. #define TINY_NVM_CMD_WORDWRITE 0x1D
  52. /* Function Prototypes: */
  53. bool TINYNVM_WaitWhileNVMBusBusy(void);
  54. bool TINYNVM_WaitWhileNVMControllerBusy(void);
  55. bool TINYNVM_EnableTPI(void);
  56. void TINYNVM_DisableTPI(void);
  57. bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
  58. uint8_t* ReadBuffer,
  59. uint16_t ReadLength);
  60. bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
  61. uint8_t* WriteBuffer,
  62. uint16_t WriteLength);
  63. bool TINYNVM_EraseMemory(const uint8_t EraseCommand,
  64. const uint16_t Address);
  65. #if (defined(INCLUDE_FROM_TINYNVM_C) && defined(ENABLE_XPROG_PROTOCOL))
  66. static void TINYNVM_SendReadNVMRegister(const uint8_t Address);
  67. static void TINYNVM_SendWriteNVMRegister(const uint8_t Address);
  68. static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress);
  69. #endif
  70. #endif