Host driver/HAL to build a LoRa Picocell Gateway which communicates through USB with a concentrator board based on Semtech SX1308 multi-channel modem and SX1257/SX1255 RF transceivers.
libloragw/inc/loragw_mcu.h@0:102b50f941d0, 2018-04-11 (annotated)
- Committer:
- dgabino
- Date:
- Wed Apr 11 14:38:42 2018 +0000
- Revision:
- 0:102b50f941d0
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dgabino | 0:102b50f941d0 | 1 | /* |
dgabino | 0:102b50f941d0 | 2 | / _____) _ | | |
dgabino | 0:102b50f941d0 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
dgabino | 0:102b50f941d0 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
dgabino | 0:102b50f941d0 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
dgabino | 0:102b50f941d0 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
dgabino | 0:102b50f941d0 | 7 | (C)2017 Semtech-Cycleo |
dgabino | 0:102b50f941d0 | 8 | |
dgabino | 0:102b50f941d0 | 9 | Description: |
dgabino | 0:102b50f941d0 | 10 | Wrapper to call MCU's HAL functions |
dgabino | 0:102b50f941d0 | 11 | |
dgabino | 0:102b50f941d0 | 12 | License: Revised BSD License, see LICENSE.TXT file include in the project |
dgabino | 0:102b50f941d0 | 13 | */ |
dgabino | 0:102b50f941d0 | 14 | |
dgabino | 0:102b50f941d0 | 15 | #ifndef _LORAGW_MCU_H |
dgabino | 0:102b50f941d0 | 16 | #define _LORAGW_MCU_H |
dgabino | 0:102b50f941d0 | 17 | |
dgabino | 0:102b50f941d0 | 18 | /* -------------------------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 19 | /* --- DEPENDANCIES --------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 20 | |
dgabino | 0:102b50f941d0 | 21 | #include <stdint.h> /* C99 types*/ |
dgabino | 0:102b50f941d0 | 22 | |
dgabino | 0:102b50f941d0 | 23 | #include "config.h" /* library configuration options (dynamically generated) */ |
dgabino | 0:102b50f941d0 | 24 | |
dgabino | 0:102b50f941d0 | 25 | #include "loragw_hal.h" |
dgabino | 0:102b50f941d0 | 26 | |
dgabino | 0:102b50f941d0 | 27 | /* -------------------------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 28 | /* --- PUBLIC CONSTANTS ----------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 29 | |
dgabino | 0:102b50f941d0 | 30 | #define LGW_MCU_SUCCESS 0 |
dgabino | 0:102b50f941d0 | 31 | #define LGW_MCU_ERROR -1 |
dgabino | 0:102b50f941d0 | 32 | |
dgabino | 0:102b50f941d0 | 33 | #define STM32FWVERSION 0x010a0006 /* increment LSB for new version */ |
dgabino | 0:102b50f941d0 | 34 | |
dgabino | 0:102b50f941d0 | 35 | #define MCU_DELAY_COM_INIT 1000 |
dgabino | 0:102b50f941d0 | 36 | #define MCU_DELAY_RESET 200 |
dgabino | 0:102b50f941d0 | 37 | |
dgabino | 0:102b50f941d0 | 38 | /* -------------------------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 39 | /* --- PUBLIC TYPES --------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 40 | |
dgabino | 0:102b50f941d0 | 41 | /* -------------------------------------------------------------------------- */ |
dgabino | 0:102b50f941d0 | 42 | /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */ |
dgabino | 0:102b50f941d0 | 43 | |
dgabino | 0:102b50f941d0 | 44 | /** |
dgabino | 0:102b50f941d0 | 45 | @brief Command to configure the board of the LoRa concentrator through MCU |
dgabino | 0:102b50f941d0 | 46 | @param conf board configuration structure to be sent to MCU |
dgabino | 0:102b50f941d0 | 47 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 48 | */ |
dgabino | 0:102b50f941d0 | 49 | int lgw_mcu_board_setconf(struct lgw_conf_board_s conf); |
dgabino | 0:102b50f941d0 | 50 | |
dgabino | 0:102b50f941d0 | 51 | /** |
dgabino | 0:102b50f941d0 | 52 | @brief Command to configure an RF chain through MCU |
dgabino | 0:102b50f941d0 | 53 | @param rfchain index of the RF chain to configure |
dgabino | 0:102b50f941d0 | 54 | @param conf RF chain configuration structure to be sent to MCU |
dgabino | 0:102b50f941d0 | 55 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 56 | */ |
dgabino | 0:102b50f941d0 | 57 | int lgw_mcu_rxrf_setconf(uint8_t rfchain, struct lgw_conf_rxrf_s conf); |
dgabino | 0:102b50f941d0 | 58 | |
dgabino | 0:102b50f941d0 | 59 | /** |
dgabino | 0:102b50f941d0 | 60 | @brief Command to configure an IF chain through MCU |
dgabino | 0:102b50f941d0 | 61 | @param ifchain index of the IF chain to configure |
dgabino | 0:102b50f941d0 | 62 | @param conf IF chain configuration structure to be sent to MCU |
dgabino | 0:102b50f941d0 | 63 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 64 | */ |
dgabino | 0:102b50f941d0 | 65 | int lgw_mcu_rxif_setconf(uint8_t ifchain, struct lgw_conf_rxif_s conf); |
dgabino | 0:102b50f941d0 | 66 | |
dgabino | 0:102b50f941d0 | 67 | /** |
dgabino | 0:102b50f941d0 | 68 | @brief Command to configure the Tx gain LUT through MCU |
dgabino | 0:102b50f941d0 | 69 | @param conf TX LUT gain table configuration structure to be sent to MCU |
dgabino | 0:102b50f941d0 | 70 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 71 | */ |
dgabino | 0:102b50f941d0 | 72 | int lgw_mcu_txgain_setconf(struct lgw_tx_gain_lut_s *conf); |
dgabino | 0:102b50f941d0 | 73 | |
dgabino | 0:102b50f941d0 | 74 | /** |
dgabino | 0:102b50f941d0 | 75 | @brief Command to receive packet from the concentrator through MCU |
dgabino | 0:102b50f941d0 | 76 | @param max_pkt maximum number of received packets |
dgabino | 0:102b50f941d0 | 77 | @param pkt_data array of packets received |
dgabino | 0:102b50f941d0 | 78 | @return number of received packets |
dgabino | 0:102b50f941d0 | 79 | */ |
dgabino | 0:102b50f941d0 | 80 | int lgw_mcu_receive(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data); |
dgabino | 0:102b50f941d0 | 81 | |
dgabino | 0:102b50f941d0 | 82 | /** |
dgabino | 0:102b50f941d0 | 83 | @brief Command to send a packet to the concentrator through MCU |
dgabino | 0:102b50f941d0 | 84 | @param pkt_data packet data to be sent to MCU |
dgabino | 0:102b50f941d0 | 85 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 86 | */ |
dgabino | 0:102b50f941d0 | 87 | int lgw_mcu_send(struct lgw_pkt_tx_s pkt_data); |
dgabino | 0:102b50f941d0 | 88 | |
dgabino | 0:102b50f941d0 | 89 | /** |
dgabino | 0:102b50f941d0 | 90 | @brief Command to get the value of the internal counter of the concentrator through MCU |
dgabino | 0:102b50f941d0 | 91 | @param data pointer to byte array that will be read from the concentrator |
dgabino | 0:102b50f941d0 | 92 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 93 | */ |
dgabino | 0:102b50f941d0 | 94 | int lgw_mcu_get_trigcnt(uint32_t *data); |
dgabino | 0:102b50f941d0 | 95 | |
dgabino | 0:102b50f941d0 | 96 | /** |
dgabino | 0:102b50f941d0 | 97 | @brief Command to store radio calibration parameters to the concentrator through MCU |
dgabino | 0:102b50f941d0 | 98 | @param idx_start start index in the MCU calibration offset table where to store the given offsets |
dgabino | 0:102b50f941d0 | 99 | @param idx_nb the number of calibration offsets to be stored in the MCU table |
dgabino | 0:102b50f941d0 | 100 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 101 | */ |
dgabino | 0:102b50f941d0 | 102 | int lgw_mcu_commit_radio_calibration(uint8_t idx_start, uint8_t idx_nb); |
dgabino | 0:102b50f941d0 | 103 | |
dgabino | 0:102b50f941d0 | 104 | /** |
dgabino | 0:102b50f941d0 | 105 | @brief Command to reset the MCU |
dgabino | 0:102b50f941d0 | 106 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 107 | */ |
dgabino | 0:102b50f941d0 | 108 | int lgw_mcu_reset(void); |
dgabino | 0:102b50f941d0 | 109 | |
dgabino | 0:102b50f941d0 | 110 | /** |
dgabino | 0:102b50f941d0 | 111 | @brief Command to get the MCU's unique ID |
dgabino | 0:102b50f941d0 | 112 | @return status of operation (LGW_MCU_SUCCESS/LGW_MCU_ERROR) |
dgabino | 0:102b50f941d0 | 113 | */ |
dgabino | 0:102b50f941d0 | 114 | int lgw_mcu_get_unique_id(uint8_t *uid); |
dgabino | 0:102b50f941d0 | 115 | |
dgabino | 0:102b50f941d0 | 116 | #endif |
dgabino | 0:102b50f941d0 | 117 | |
dgabino | 0:102b50f941d0 | 118 | /* --- EOF ------------------------------------------------------------------ */ |