@@ -67,6 +67,8 @@ static const RAIL_CsmaConfig_t csma_config = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_
67
67
#if defined(TARGET_EFR32MG1)
68
68
#include " ieee802154_subg_efr32xg1_configurator_out.h"
69
69
#include " ieee802154_efr32xg1_configurator_out.h"
70
+ #elif defined(TARGET_EFR32MG12)
71
+ #include " ieee802154_efr32xg12_configurator_out.h"
70
72
#else
71
73
#error "Not a valid target."
72
74
#endif
@@ -78,23 +80,23 @@ static const RAIL_ChannelConfigEntry_t entry[] = {
78
80
};
79
81
80
82
#if MBED_CONF_SL_RAIL_BAND == 868
81
- #ifndef DEVICE_RF_SUBGHZ
83
+ #ifndef MBED_CONF_SL_RAIL_HAS_SUBGIG
82
84
#error "Sub-Gigahertz band is not supported on this target."
83
85
#endif
84
86
static const RAIL_ChannelConfig_t channels = {
85
87
(RAIL_ChannelConfigEntry_t *) &entry[0 ],
86
88
1
87
89
};
88
90
#elif MBED_CONF_SL_RAIL_BAND == 915
89
- #ifndef DEVICE_RF_SUBGHZ
91
+ #ifndef MBED_CONF_SL_RAIL_HAS_SUBGIG
90
92
#error "Sub-Gigahertz band is not supported on this target."
91
93
#endif
92
94
static const RAIL_ChannelConfig_t channels = {
93
95
(RAIL_ChannelConfigEntry_t *) &entry[1 ],
94
96
1
95
97
};
96
98
#elif MBED_CONF_SL_RAIL_BAND == 2400
97
- #ifndef DEVICE_RF_2P4GHZ
99
+ #ifndef MBED_CONF_SL_RAIL_HAS_2P4
98
100
#error "2.4GHz band is not supported on this target."
99
101
#endif
100
102
static const RAIL_ChannelConfig_t channels = {
@@ -111,7 +113,7 @@ static const RAIL_IEEE802154_Config_t config = { false, false,
111
113
112
114
static const RAIL_Init_t railInitParams = { 140 , 38400000 , RAIL_CAL_ALL_PENDING };
113
115
114
- #if defined (DEVICE_RF_2P4GHZ )
116
+ #if defined (MBED_CONF_SL_RAIL_HAS_2P4 )
115
117
// Set up the PA for 2.4 GHz operation
116
118
static const RADIO_PAInit_t paInit2p4 = {
117
119
PA_SEL_2P4_HP, /* Power Amplifier mode */
@@ -122,7 +124,7 @@ static const RADIO_PAInit_t paInit2p4 = {
122
124
};
123
125
#endif
124
126
125
- #if defined (DEVICE_RF_SUBGHZ )
127
+ #if defined (MBED_CONF_SL_RAIL_HAS_SUBGIG )
126
128
// Set up the PA for sub-GHz operation
127
129
static const RADIO_PAInit_t paInitSubGhz = {
128
130
PA_SEL_SUBGIG, /* Power Amplifier mode */
@@ -173,21 +175,19 @@ static int8_t rf_device_register(void)
173
175
#endif
174
176
175
177
// Set up PTI since it makes life so much easier
176
- #if defined(DEVICE_SL_PTI )
178
+ #if defined(MBED_CONF_SL_RAIL_PTI) && (MBED_CONF_SL_RAIL_PTI == 1 )
177
179
RADIO_PTIInit_t ptiInit = {
178
- RADIO_PTI_MODE_UART,
179
- 1600000 ,
180
- 6 ,
181
- // TODO: Configure PTI pinout using config system.
182
- // Not very urgent, since all boards use the same pins now.
183
- gpioPortB,
184
- 12 ,
185
- 6 ,
186
- gpioPortB,
187
- 11 ,
188
- 6 ,
189
- gpioPortB,
190
- 13 ,
180
+ MBED_CONF_SL_RAIL_PTI_MODE,
181
+ MBED_CONF_SL_RAIL_PTI_BAUDRATE,
182
+ MBED_CONF_SL_RAIL_PTI_DOUT_LOCATION,
183
+ MBED_CONF_SL_RAIL_PTI_DOUT_PORT,
184
+ MBED_CONF_SL_RAIL_PTI_DOUT_PIN,
185
+ MBED_CONF_SL_RAIL_PTI_DCLK_LOCATION,
186
+ MBED_CONF_SL_RAIL_PTI_DCLK_PORT,
187
+ MBED_CONF_SL_RAIL_PTI_DCLK_PIN,
188
+ MBED_CONF_SL_RAIL_PTI_DFRAME_LOCATION,
189
+ MBED_CONF_SL_RAIL_PTI_DFRAME_PORT,
190
+ MBED_CONF_SL_RAIL_PTI_DFRAME_PIN
191
191
};
192
192
193
193
RADIO_PTI_Init (&ptiInit);
@@ -196,13 +196,13 @@ static int8_t rf_device_register(void)
196
196
// Set up RAIL
197
197
RAIL_RfInit (&railInitParams);
198
198
RAIL_ChannelConfig (&channels);
199
- #if MBED_CONF_SL_RAIL_BAND == 2400
199
+ #if ( MBED_CONF_SL_RAIL_BAND == 2400)
200
200
RAIL_RadioConfig ((void *) ieee802154_config_base);
201
201
channel = 11 ;
202
202
#elif (MBED_CONF_SL_RAIL_BAND == 915)
203
203
RAIL_RadioConfig ((void *) ieee802154_config_915);
204
204
channel = 1 ;
205
- #elif MBED_CONF_SL_RAIL_BAND == 868
205
+ #elif ( MBED_CONF_SL_RAIL_BAND == 868)
206
206
RAIL_RadioConfig ((void *) ieee802154_config_863);
207
207
channel = 0 ;
208
208
#endif
@@ -286,8 +286,6 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
286
286
data_length + 3
287
287
};
288
288
289
- tr_debug (" Called TX, len %d, chan %d\n " , data_length, channel);
290
-
291
289
switch (radio_state) {
292
290
case RADIO_UNINIT:
293
291
tr_debug (" Radio uninit\n " );
@@ -327,6 +325,8 @@ static int8_t rf_start_cca(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_h
327
325
txOpt.waitForAck = false ;
328
326
}
329
327
328
+ // tr_debug("Called TX, len %d, chan %d, ack %d\n", data_length, channel, waiting_for_ack ? 1 : 0);
329
+
330
330
if (RAIL_TxStartWithOptions (channel, &txOpt, &RAIL_CcaCsma, (RAIL_CsmaConfig_t*) &csma_config) == 0 ) {
331
331
// Save packet number and sequence
332
332
current_tx_handle = tx_handle;
@@ -612,7 +612,6 @@ void RAILCb_RfReady(void) {
612
612
* @param[in] status A bit field that defines what event caused the callback
613
613
*/
614
614
void RAILCb_TxRadioStatus (uint8_t status) {
615
- tr_debug (" Packet TX error %d\n " , status);
616
615
if (device_driver.phy_tx_done_cb != NULL ) {
617
616
if (status == RAIL_TX_CONFIG_BUFFER_UNDERFLOW ||
618
617
status == RAIL_TX_CONFIG_CHANNEL_BUSY ||
@@ -624,6 +623,8 @@ void RAILCb_TxRadioStatus(uint8_t status) {
624
623
PHY_LINK_CCA_FAIL,
625
624
8 ,
626
625
1 );
626
+ } else {
627
+ tr_debug (" Packet TX error %d\n " , status);
627
628
}
628
629
}
629
630
radio_state = RADIO_RX;
@@ -643,7 +644,13 @@ void RAILCb_TxRadioStatus(uint8_t status) {
643
644
* @param[in] status The event that triggered this callback
644
645
*/
645
646
void RAILCb_RxRadioStatus (uint8_t status) {
646
- tr_debug (" RXE %d\n " , status);
647
+ switch (status) {
648
+ case RAIL_RX_CONFIG_ADDRESS_FILTERED:
649
+ break ;
650
+ default :
651
+ tr_debug (" RXE %d\n " , status);
652
+ break ;
653
+ }
647
654
}
648
655
649
656
/* *
@@ -724,10 +731,10 @@ void RAILCb_RxPacketReceived(void *rxPacketHandle) {
724
731
/* Save the pending bit */
725
732
last_ack_pending_bit = (rxPacketInfo->dataPtr [1 ] & (1 << 4 )) != 0 ;
726
733
/* Tell the stack we got an ACK */
727
- tr_debug (" rACK\n " );
734
+ // tr_debug("rACK\n");
728
735
device_driver.phy_tx_done_cb ( rf_radio_driver_id,
729
736
current_tx_handle,
730
- PHY_LINK_TX_DONE,
737
+ last_ack_pending_bit ? PHY_LINK_TX_DONE_PENDING : PHY_LINK_TX_DONE,
731
738
1 ,
732
739
1 );
733
740
} else {
@@ -745,7 +752,7 @@ void RAILCb_RxPacketReceived(void *rxPacketHandle) {
745
752
RAIL_AutoAckCancelAck ();
746
753
}
747
754
748
- tr_debug (" rPKT %d\n " , rxPacketInfo->dataLength );
755
+ // tr_debug("rPKT %d\n", rxPacketInfo->dataLength);
749
756
/* Feed the received packet into the stack */
750
757
device_driver.phy_rx_cb (rxPacketInfo->dataPtr + 1 ,
751
758
rxPacketInfo->dataLength - 1 ,
@@ -785,6 +792,7 @@ void RAILCb_IEEE802154_DataRequestCommand(RAIL_IEEE802154_Address_t *address) {
785
792
*/
786
793
void RAILCb_RxAckTimeout (void ) {
787
794
if (waiting_for_ack) {
795
+ tr_debug (" nACK\n " );
788
796
waiting_for_ack = false ;
789
797
device_driver.phy_tx_done_cb ( rf_radio_driver_id,
790
798
current_tx_handle,
@@ -824,4 +832,59 @@ static bool rail_checkAndSwitchChannel(uint8_t newChannel) {
824
832
} else {
825
833
return false ;
826
834
}
835
+ }
836
+
837
+ /* *
838
+ * Callback that fires when the receive fifo exceeds the configured threshold
839
+ * value
840
+ *
841
+ * @param[in] bytesAvailable Number of bytes available in the receive fifo at
842
+ * the time of the callback dispatch
843
+ *
844
+ * @return void
845
+ * @warning You must implement a stub for this in your RAIL application.
846
+ *
847
+ * Callback that fires when the receive fifo exceeds the configured threshold
848
+ * value. Provides the number of bytes available in the receive fifo at the
849
+ * time of the callback dispatch.
850
+ */
851
+ void RAILCb_RxFifoAlmostFull (uint16_t bytesAvailable) {
852
+ tr_debug (" RX near full (%d)\n " , bytesAvailable);
853
+ }
854
+
855
+ /* *
856
+ * Callback that fires when the transmit fifo falls under the configured
857
+ * threshold value
858
+ *
859
+ * @param[in] spaceAvailable Number of bytes open in the transmit fifo at the
860
+ * time of the callback dispatch
861
+ *
862
+ * @return void
863
+ * @warning You must implement a stub for this in your RAIL application.
864
+ *
865
+ * Callback that fires when the transmit fifo falls under the configured
866
+ * threshold value. It only fires if a rising edge occurs across this
867
+ * threshold. This callback will not fire on initailization nor after resetting
868
+ * the transmit fifo with RAIL_ResetFifo().
869
+ *
870
+ * Provides the number of bytes open in the transmit fifo at the time of the
871
+ * callback dispatch.
872
+ */
873
+ void RAILCb_TxFifoAlmostEmpty (uint16_t spaceAvailable) {
874
+ tr_debug (" TX near empty (%d)\n " , spaceAvailable);
875
+ }
876
+
877
+ /* *
878
+ * Callback for when AGC averaged RSSI is done
879
+ *
880
+ * @param avgRssi Contains the the RSSI in quarter dBm (dbm*4) on success and
881
+ * returns \ref RAIL_RSSI_INVALID if there was a problem computing the result.
882
+ *
883
+ * Called in response to RAIL_StartAverageRSSI() to indicate that the hardware
884
+ * has completed averaging. If you would like you can instead use the
885
+ * RAIL_AverageRSSIReady() to wait for completion and RAIL_GetAverageRSSI() to
886
+ * get the result.
887
+ */
888
+ void RAILCb_RssiAverageDone (int16_t avgRssi) {
889
+ tr_debug (" RSSI done (%d)\n " , avgRssi);
827
890
}
0 commit comments