radio.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /* Data Structures */
  11. typedef enum {
  12. NOT_CONFIGURED = 0,
  13. AX25,
  14. ARROW_MESH,
  15. ESP_MESH,
  16. } radio_config_t;
  17. typedef enum {
  18. RADIO_IDLE = 0,
  19. RADIO_TX,
  20. RADIO_RX,
  21. } radio_status_t;
  22. // internal radio data structure
  23. typedef struct {
  24. radio_config_t type;
  25. radio_status_t status;
  26. void (*rx_cb)(uint8_t *, uint32_t);
  27. void (*tx_cb)(void);
  28. } radio_param_t;
  29. // holds all the settings for AX25
  30. // style communications used typically
  31. // on 2M band
  32. typedef struct {
  33. uint8_t tx_delay;
  34. uint8_t tx_tail;
  35. uint32_t sample_rate;
  36. uint32_t symbol0_freq;
  37. uint32_t symbol1_freq;
  38. uint8_t *rx_buf;
  39. uint32_t rx_buf_len;
  40. void (*rx_cb)(uint8_t *, uint32_t);
  41. void (*tx_cb)(void);
  42. uint8_t cpu_core;
  43. } ax25_param_t;
  44. /* Public Functions */
  45. void radio_init(radio_config_t type, void *settings);
  46. void radio_set_frequency(uint32_t);
  47. void radio_set_power(int8_t);
  48. uint8_t radio_get_cs(void);
  49. int8_t radio_get_rssi(void);
  50. int8_t radio_get_sample(void);
  51. void radio_packet_rx(void *settings);
  52. void radio_packet_tx(uint8_t *data, int32_t len, void *settings);
  53. #endif /* COMPONENTS_RADIO_INCLUDE_RADIO_H_ */