| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef __LORA_H__
- #define __LORA_H__
- #include "stm32f10x.h"
- #include "project_config.h"
- #include "tools.h"
- #include "os.h"
- //#define LORA_DEBUG_EN 1
- #ifdef LORA_DEBUG_EN
- #define LORA_DEBUG(fmt, x...) \
- do \
- { \
- printf(fmt,##x); \
- }while(0)
- #define LORA_DEBUG_F(fmt, x...) \
- do \
- { \
- printf("\r\n%s(Line %d): "fmt,__FUNCTION__,__LINE__, ##x); \
- }while(0)
- #else
- #define LORA_DEBUG(fmt, x...)
- #define LORA_DEBUG_H(fmt, x...)
- #define LORA_DEBUG_F(fmt, x...)
- #endif
- extern volatile uint32_t TickCounter;
- #define MODE_TIMEOUT 3000
- extern timeout_t tt_lora_rcv_state;
- extern timeout_t tt_lora_rst_rcv_state;
- extern timeout_t tt_lora_irq;
- typedef enum LORA_STATE_ENUM {
- lora_state_idle,
- lora_state_rcv,
- lora_state_send,
- lora_state_cad,
-
- lora_state_rcvRunning,
- lora_state_sendRunning,
- lora_state_cadRunning,
- lora_state_cadTimeout,
- lora_state_cadDone,
- lora_state_max
- } LORA_STATE_ENUM;
- extern uint8_t lora_state;
- #define SYS_LORA_RX 1
- #define SYS_LORA_TX 2
- #define LORA_DELAY_TIME_BASE 150
- #define LORA_DELAY_TIME_ADD_MAX 50
- typedef struct _system_lora {
- uint8_t memory[8][256]; //必须4字节对齐
- OS_Q lora_q;
- OS_SEM sem;
- OS_MEM lora_m;
- OS_TMR lora_tmr;
- } system_lora_t;
- extern system_lora_t sys_lora_rx;
- extern system_lora_t sys_lora_tx;
- //lora参数
- typedef struct _lora_para_single
- {
- uint32_t lora_fre; // 收发频率
- uint8_t lora_tx_output_power; // 测试默认使用的发射功率,126x发射功率0~22dbm,127x发射功率2~20dbm
- uint8_t lora_bandwidth; // [0: 125 kHz, 测试默认使用的带宽,sx126x:[0: 125 kHz,1: 250 kHz,2: 500 kHz,3: Reserved]
- uint8_t lora_spreading_factor; // 测试默认使用的扩频因子范围7~12
- uint8_t lora_codingrate; // 测试默认使用的纠错编码率[1: 4/5,2: 4/6,3: 4/7,4: 4/8]
- uint16_t lora_preamble_length; // 前导码长度
- // uint8_t reserve[2]; // 预留
- }__attribute__((packed)) lora_para_single_t;
- typedef struct _lora_para
- {
- lora_para_single_t lora_para_group[4];
- }__attribute__((packed)) lora_para_t;
- extern lora_para_t lora_para;
- extern uint8_t lora_para_choice;
- extern lora_para_single_t lora_para_fixed[];
- void lora_queue_init(void);
- void* lora_queue_mem_calloc_must(uint8_t state);
- int lora_queue_mem_free(uint8_t state,void * p_msg);
- void lora_queue_insert(uint8_t state,char *p_msg, uint32_t msg_len);
- void lora_queue_init(void);
- void lora_init(void);
- void lora_task(void);
- void lora_rcv_interval_set(uint8_t state);
- void lora_queue_proc_rx(void);
- void lora_queue_proc_tx(void);
- void lora_queue_delete(uint8_t state);
- #endif
|