Lorawan.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __LORAWAN_H
  2. #define __LORAWAN_H
  3. #include "stm32f10x.h"
  4. typedef enum {
  5. MODE_INT,
  6. MODE_CMD, //mode pin high
  7. MODE_TRANSPARENT,
  8. } LoraNode_Mode_T;
  9. /*
  10. typedef enum {
  11. NET_ABP,
  12. NET_OTAA,
  13. } LoraNode_NetMode_T;
  14. */
  15. typedef enum {
  16. MODE_WAKEUP,
  17. MODE_SLEEP,
  18. } LoraNode_SleepMode_T;
  19. /*
  20. typedef struct {
  21. uint8_t DevEUI[8];
  22. uint8_t AppEUI[8];
  23. uint8_t DevADDR[4];
  24. uint8_t AppKEY[16];
  25. uint8_t AppSKEY[16];
  26. uint8_t NwkSKEY[16];
  27. uint8_t Join;
  28. LoraNode_Mode_T MODE;
  29. uint8_t ONline;
  30. uint8_t BUSY;
  31. uint8_t NET_Mode;
  32. uint8_t Confirm;
  33. } Node_Info;
  34. typedef struct {
  35. uint8_t Up_Result;
  36. uint8_t Up_CH;
  37. uint8_t Up_RATE;
  38. uint8_t Up_DB;
  39. uint32_t Up_Link;
  40. uint16_t Up_Cache;
  41. uint16_t Resend;
  42. } Send_Info;
  43. */
  44. /* Lorawan Node pin configuration */
  45. #define LORANODE_WAKE_PIN GPIO_Pin_4
  46. #define LORANODE_WAKE_GPIO_PORT GPIOC
  47. #define LORANODE_MODE_PIN GPIO_Pin_7
  48. #define LORANODE_MODE_GPIO_PORT GPIOC
  49. #define LORANODE_NRST_PIN GPIO_Pin_7
  50. #define LORANODE_NRST_GPIO_PORT GPIOA
  51. /* INPUT */
  52. #define LORANODE_STAT_PIN GPIO_Pin_8
  53. #define LORANODE_STAT_GPIO_PORT GPIOC
  54. #define LORANODE_BUSY_PIN GPIO_Pin_0
  55. #define LORANODE_BUSY_GPIO_PORT GPIOB
  56. /* stop the wfi sleep */
  57. #define LORANODE_GPIO_PORT LORANODE_BUSY_GPIO_PORT //LORANODE_STAT_GPIO_PORT
  58. #define LORANODE_WAKE_HIGH() GPIO_WriteBit(LORANODE_WAKE_GPIO_PORT, LORANODE_WAKE_PIN, Bit_SET)
  59. #define LORANODE_WAKE_LOW() GPIO_WriteBit(LORANODE_WAKE_GPIO_PORT, LORANODE_WAKE_PIN, Bit_RESET)
  60. #define LORANODE_MODE_HIGH() GPIO_WriteBit(LORANODE_MODE_GPIO_PORT, LORANODE_MODE_PIN, Bit_SET)
  61. #define LORANODE_MODE_LOW() GPIO_WriteBit(LORANODE_MODE_GPIO_PORT, LORANODE_MODE_PIN, Bit_RESET)
  62. #define LORANODE_NRST_HIGH() GPIO_WriteBit(LORANODE_NRST_GPIO_PORT, LORANODE_NRST_PIN, Bit_SET)
  63. #define LORANODE_NRST_LOW() GPIO_WriteBit(LORANODE_NRST_GPIO_PORT, LORANODE_NRST_PIN, Bit_RESET)
  64. #define LORANODE_STAT_STATUS GPIO_ReadInputDataBit(LORANODE_STAT_GPIO_PORT, LORANODE_STAT_PIN)
  65. #define LORANODE_BUSY_STATUS GPIO_ReadInputDataBit(LORANODE_BUSY_GPIO_PORT, LORANODE_BUSY_PIN)
  66. #define LORANODE_MODE_STATUS GPIO_ReadOutputDataBit(LORANODE_MODE_GPIO_PORT, LORANODE_MODE_PIN)
  67. uint8_t StrToHex(uint8_t temp);
  68. void LoraNode_GPIO_Init(void);
  69. void LoraNode_Init_Mode(LoraNode_Mode_T mode);
  70. void LoraNode_Wake_Sleep(LoraNode_SleepMode_T mode);
  71. static void LoraNode_Reset(void);
  72. void LoraNode_OTAA_Config(void);
  73. void transparent_send_data(uint8_t *DataBuf, uint32_t xmitLen); //ÔÚ͸´«Ä£Ê½Ï·¢ËÍÊý¾Ý
  74. void lorawan_Sleep(void);
  75. #endif