|
20 | 20 | /* Internals */ |
21 | 21 |
|
22 | 22 | /* Internal events to scheduler thread */ |
23 | | -#define DECT_PHY_API_EVENT_SCHEDULER_NEXT_FRAME 1 |
24 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_COMPLETED 2 |
25 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_PDC_DATA_RECEIVED 3 |
26 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_PURGE 4 |
27 | | -#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON 5 |
28 | | -#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_OFF 6 |
29 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND 7 |
30 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_RESUME 8 |
31 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_ON 9 |
32 | | -#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_OFF 10 |
| 23 | +#define DECT_PHY_API_EVENT_SCHEDULER_NEXT_FRAME 1 |
| 24 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_COMPLETED 2 |
| 25 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_PDC_DATA_RECEIVED 3 |
| 26 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_PURGE 4 |
| 27 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC 5 |
| 28 | +#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON 6 |
| 29 | +#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_OFF 7 |
| 30 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND 8 |
| 31 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_RESUME 9 |
| 32 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_ON 10 |
| 33 | +#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_OFF 11 |
33 | 34 |
|
34 | 35 | /* Scheduler states */ |
35 | 36 | enum dect_phy_api_scheduler_state { |
@@ -278,6 +279,13 @@ dect_phy_api_scheduler_list_item_remove_by_phy_op_handle(uint16_t handle) |
278 | 279 | return iterator; |
279 | 280 | } |
280 | 281 |
|
| 282 | +void dect_phy_api_scheduler_th_list_item_remove_dealloc_by_phy_op_handle(uint16_t handle) |
| 283 | +{ |
| 284 | + (void)dect_phy_api_scheduler_raise_event_with_data( |
| 285 | + DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC, (void *)&handle, |
| 286 | + sizeof(uint16_t)); |
| 287 | +} |
| 288 | + |
281 | 289 | void dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle(uint16_t handle) |
282 | 290 | { |
283 | 291 | struct dect_phy_api_scheduler_list_item *iterator = NULL; |
@@ -687,6 +695,24 @@ struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_ |
687 | 695 | return p_elem; |
688 | 696 | } |
689 | 697 |
|
| 698 | +struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_rssi_element( |
| 699 | + struct dect_phy_api_scheduler_list_item_config **item_conf) |
| 700 | +{ |
| 701 | + struct dect_phy_api_scheduler_list_item *p_elem = |
| 702 | + k_calloc(1, sizeof(struct dect_phy_api_scheduler_list_item)); |
| 703 | + |
| 704 | + if (p_elem == NULL) { |
| 705 | + printk("%s: cannot allocate memory for scheduler list item\n", (__func__)); |
| 706 | + return NULL; |
| 707 | + } |
| 708 | + p_elem->priority = DECT_PRIORITY1_RX_RSSI; |
| 709 | + p_elem->sched_config.tx.encoded_payload_pdu = NULL; |
| 710 | + p_elem->silent_fail = false; |
| 711 | + *item_conf = &p_elem->sched_config; |
| 712 | + |
| 713 | + return p_elem; |
| 714 | +} |
| 715 | + |
690 | 716 | void dect_phy_api_scheduler_list_item_dealloc(struct dect_phy_api_scheduler_list_item *list_item) |
691 | 717 | { |
692 | 718 | if (list_item != NULL) { |
@@ -1033,6 +1059,15 @@ dect_phy_api_scheduler_core_mdm_phy_op(struct dect_phy_api_scheduler_list_item * |
1033 | 1059 | DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON); |
1034 | 1060 | #endif |
1035 | 1061 | } |
| 1062 | + } else if (list_item->priority == DECT_PRIORITY1_RX_RSSI) { |
| 1063 | + struct nrf_modem_dect_phy_rssi_params rssi_params = |
| 1064 | + list_item->sched_config.rssi.rssi_op_params; |
| 1065 | + |
| 1066 | + err = nrf_modem_dect_phy_rssi(&rssi_params); |
| 1067 | + if (err) { |
| 1068 | + desh_error("(%s): nrf_modem_dect_phy_rssi failed %d", |
| 1069 | + (__func__), err); |
| 1070 | + } |
1036 | 1071 | } else { |
1037 | 1072 | struct nrf_modem_dect_phy_rx_params rx_op = { |
1038 | 1073 | .rssi_interval = NRF_MODEM_DECT_PHY_RSSI_INTERVAL_OFF, |
@@ -1155,6 +1190,10 @@ static void dect_phy_api_scheduler_core_tick_th_schedule_next_frame(void) |
1155 | 1190 | } |
1156 | 1191 | iterator->phy_op_handle = next_handle; |
1157 | 1192 | } |
| 1193 | + if (iterator->priority == DECT_PRIORITY1_RX_RSSI) { |
| 1194 | + iterator->sched_config.rssi.rssi_op_params.start_time = |
| 1195 | + new_frame_time; |
| 1196 | + } |
1158 | 1197 |
|
1159 | 1198 | if (!dect_phy_api_scheduler_list_item_add(iterator)) { |
1160 | 1199 | printk("(%s)/1: dect_phy_api_scheduler_list_item_add for " |
@@ -1274,6 +1313,10 @@ static void dect_phy_api_scheduler_core_tick_th_schedule_next_frame(void) |
1274 | 1313 | } |
1275 | 1314 | iterator->phy_op_handle = next_handle; |
1276 | 1315 | } |
| 1316 | + if (iterator->priority == DECT_PRIORITY1_RX_RSSI) { |
| 1317 | + iterator->sched_config.rssi.rssi_op_params.start_time = |
| 1318 | + new_frame_time; |
| 1319 | + } |
1277 | 1320 |
|
1278 | 1321 | if (!dect_phy_api_scheduler_list_item_add(iterator)) { |
1279 | 1322 | desh_error("(%s): dect_phy_api_scheduler_list_item_add " |
@@ -1406,6 +1449,13 @@ static void dect_phy_api_scheduler_th_handler(void) |
1406 | 1449 | dect_phy_api_scheduler_done_list_purge(); |
1407 | 1450 | break; |
1408 | 1451 | } |
| 1452 | + case DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC: { |
| 1453 | + uint16_t *phy_handle = (uint16_t *)event.data; |
| 1454 | + |
| 1455 | + dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle( |
| 1456 | + *phy_handle); |
| 1457 | + break; |
| 1458 | + } |
1409 | 1459 | case DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND: { |
1410 | 1460 | scheduler_data.state = SCHEDULER_STATE_SUSPENDED; |
1411 | 1461 | dect_phy_api_scheduler_done_list_items_stop_in_modem(); |
|
0 commit comments