radio.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * radio.h
  3. *
  4. * Created on: Oct 11, 2019
  5. * Author: curiousmuch
  6. */
  7. #include <stdint.h>
  8. #ifndef RADIO_H_
  9. #define RADIO_H_
  10. #include "freertos/task.h"
  11. /* Data Structures */
  12. typedef enum {
  13. NOT_CONFIGURED = 0,
  14. AX25,
  15. ARROW_NARROWBAND,
  16. ESP_MESH,
  17. } radio_config_t;
  18. typedef enum {
  19. RADIO_IDLE = 0,
  20. RADIO_TX,
  21. RADIO_RX,
  22. } radio_status_t;
  23. // internal radio data structure
  24. typedef struct {
  25. radio_config_t type;
  26. radio_status_t status;
  27. void (*rx_cb)(uint8_t *, uint32_t);
  28. void (*tx_cb)(void);
  29. TaskHandle_t tx_task;
  30. TaskHandle_t rx_task;
  31. } radio_param_t;
  32. // holds all the settings for AX25
  33. // style communications used typically
  34. // on 2M band
  35. typedef struct {
  36. uint8_t tx_delay;
  37. uint8_t tx_tail;
  38. uint32_t sample_rate;
  39. uint32_t symbol0_freq;
  40. uint32_t symbol1_freq;
  41. uint8_t *rx_buf;
  42. uint32_t rx_buf_len;
  43. void (*rx_cb)(uint8_t *, uint32_t);
  44. void (*tx_cb)(void);
  45. uint8_t cpu_core;
  46. } ax25_param_t;
  47. /* Public Functions */
  48. void radio_init(radio_config_t type, void *settings);
  49. void radio_reinit(radio_config_t type, void *settings);
  50. void radio_set_frequency(uint32_t);
  51. void radio_set_power(int8_t);
  52. uint8_t radio_get_cs(void);
  53. int8_t radio_get_rssi(void);
  54. int8_t radio_get_sample(void);
  55. void radio_packet_rx(void *settings);
  56. void radio_packet_tx(uint8_t *data, int32_t len, void *settings);
  57. #endif /* COMPONENTS_RADIO_INCLUDE_RADIO_H_ */