hpw421初始版本

This commit is contained in:
xushaoxiang
2026-06-06 16:49:48 +08:00
commit 2339bbfd1f
3283 changed files with 860261 additions and 0 deletions
+138
View File
@@ -0,0 +1,138 @@
/**
****************************************************************************************
*
* @file sch_alarm.h
*
* @brief sch_alarm main module
*
* Copyright (C) RivieraWaves 2009-2017
*
*
****************************************************************************************
*/
#ifndef _SCH_ALARM_H_
#define _SCH_ALARM_H_
/**
****************************************************************************************
* @addtogroup SCH
* @brief Entry points of the Scheduling alaram module
*
* @{
****************************************************************************************
*/
#include "rwip_config.h"
#include <stdint.h> // Standard integer definitions
#include <stdbool.h> // Standard boolean definitions
#include "co_list.h" // List management functions definitions
/*
* MACROS
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/*
* DEFINITIONS
****************************************************************************************
*/
/// SCH_ALARM error codes
enum sch_alarm_error
{
/// SCH_ALARM request succeed
SCH_ALARM_ERROR_OK = 0,
/// SCH_ALARM request rejected error
SCH_ALARM_ERROR_REJECTED,
/// SCH_ALARM element not found error
SCH_ALARM_ERROR_NOT_FOUND,
/// SCH_ALARM request rejected due to bandwidth full error
SCH_ALARM_ERROR_BW_FULL
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Alarm element structure
struct sch_alarm_tag
{
/// List element for chaining in the Even Arbiter lists
struct co_list_hdr hdr;
/// Timestamp of alarm expiry (in BT half-slots and half-us)
rwip_tgt_timer_t time;
/// Call back function invoked upon alarm expiry
void (*cb_alarm)(struct sch_alarm_tag*);
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the Scheduling alarm.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void sch_alarm_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Alarm interrupt handler
*
* This function is called under interrupt when an alarm is triggered.
*
****************************************************************************************
*/
void sch_alarm_timer_isr(void);
/**
****************************************************************************************
* @brief Set an alarm
*
* If the alarm specify an instant in the past, the alarm is scheduled for earliest
* possible time.
*
* @param[in] elt Pointer to the alarm element to be programmed
****************************************************************************************
*/
void sch_alarm_set(struct sch_alarm_tag* elt);
/**
****************************************************************************************
* @brief Clear an alarm
*
* @param[in] elt Pointer to the alarm element to be cleared
*
* @return 0 - no error / 1:255 - error
****************************************************************************************
*/
uint8_t sch_alarm_clear(struct sch_alarm_tag* elt);
///@} SCH_ALARM
#endif // _SCH_ALARM_H_
+270
View File
@@ -0,0 +1,270 @@
/**
****************************************************************************************
*
* @file SCH_ARB.h
*
* @brief SCH_ARB main module
*
* Copyright (C) RivieraWaves 2009-2017
*
*
****************************************************************************************
*/
#ifndef _SCH_ARB_H_
#define _SCH_ARB_H_
/**
****************************************************************************************
* @addtogroup SCH
* @brief Entry points of the Scheduling Arbiter module
*
* This module contains the primitives that allow stacks to schedule an event or frame.
*
* @{
****************************************************************************************
*/
#include "rwip_config.h"
#include <stdint.h> // Standard integer definitions
#include <stdbool.h> // Standard boolean definitions
#include "co_list.h" // List management functions definitions
#include "rwip.h" // For rwip_time_t
/*
* MACROS
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/// Default BW 2 slots
#define SCH_ARB_BW_USED_DFT_SLOT (2)
#define SCH_ARB_BW_USED_DFT_US (SCH_ARB_BW_USED_DFT_SLOT*SLOT_SIZE)
/// Set ASAP settings
#define SCH_ARB_ASAP_STG_SET(evt, type, phase, resched_att, prio_inc) evt->asap_settings = ( (((type) << 14) & 0xC000) | (((phase) << 11) & 0x3800) | (((resched_att) << 6) & 0x03C0) | (((prio_inc) << 0) & 0x003F) );
/// Get/Set type from ASAP settings
#define SCH_ARB_ASAP_STG_TYPE_GET(evt) ((uint8_t)((evt->asap_settings & 0xC000) >> 14))
#define SCH_ARB_ASAP_STG_TYPE_SET(evt, type) ( evt->asap_settings = ((evt->asap_settings & ~(0xC000)) | (((type) << 14) & 0xC000)) )
/// Get phase from ASAP settings
#define SCH_ARB_ASAP_STG_PHASE_GET(evt) ((uint8_t)((evt->asap_settings & 0x3800) >> 11))
/// Get/Set rescheduling attempts from ASAP settings
#define SCH_ARB_ASAP_STG_RESCHED_ATT_GET(evt) ((uint8_t)((evt->asap_settings & 0x03C0) >> 6))
#define SCH_ARB_ASAP_STG_RESCHED_ATT_SET(evt, resched_att) ( evt->asap_settings = ((evt->asap_settings & ~(0x03C0)) | (((resched_att) << 6) & 0x03C0)) )
/// Get priority increment from ASAP settings
#define SCH_ARB_ASAP_STG_PRIO_INC_GET(evt) ((uint8_t)((evt->asap_settings & 0x003F) >> 0))
/// Maximum SCH_ARB element duration in half-us
#define SCH_ARB_MAX_DURATION (400000)
/*
* DEFINITIONS
****************************************************************************************
*/
/// SCH_ARB error codes
enum sch_arb_error
{
/// SCH_ARB request succeed
SCH_ARB_ERROR_OK = 0,
/// SCH_ARB request rejected error
SCH_ARB_ERROR_REJECTED,
/// SCH_ARB element not found error
SCH_ARB_ERROR_NOT_FOUND,
/// SCH_ARB request rejected due to bandwidth full error
SCH_ARB_ERROR_BW_FULL
};
/// ASAP type definition
/*@TRACE*/
enum sch_arb_elt_asap_type
{
/// 00: No ASAP
SCH_ARB_FLAG_NO_ASAP = 0,
/// 01: ASAP no limit
SCH_ARB_FLAG_ASAP_NO_LIMIT,
/// 10: ASAP with limit
SCH_ARB_FLAG_ASAP_LIMIT,
SCH_ARB_FLAG_MAX
};
/// ASAP slot parity definition
enum sch_arb_elt_asap_phase
{
SCH_ARB_PHASE_0,
SCH_ARB_PHASE_1,
SCH_ARB_PHASE_2,
SCH_ARB_PHASE_3,
SCH_ARB_NO_PHASE,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Scheduling Arbiter Element
/*@TRACE*/
struct sch_arb_elt_tag
{
/// List element for chaining in the Even Arbiter lists
struct co_list_hdr hdr;
/// Programming time expressed in half-slots and half-us
rwip_time_t time;
/// Scheduling time limit in base time (half-slots) (only for ASAP LIMIT requests)
uint32_t asap_limit;
/// Minimum duration of the event or frame (in half-us)
uint32_t duration_min;
/**
* ASAP settings field
* bit |15 14|13 12 11| 10 | 9..6 | 5..0 |
* def | TYPE | Phase | To protect | Resched att | Prio inc |
*
* Type:
* - 00: No ASAP
* - 01: ASAP no limit
* - 10: ASAP with limit
* - 11: ASAP with limit, no parity check
*
* Phase: (only for ASAP requests)
* - 0: phase 0
* - 1: phase 1
* - 2: phase 2
* - 3: phase 3
* - 4: don't care
*
* Number of rescheduling attempts:
* - The remaining number of rescheduling attempts.
* - Rescheduling happens when the event is overlapped by a higher priority event
* - Only used for ASAP requests
*
* Priority increment:
* - The current priority value is incremented each time the event is overlapped by a new insertion and postponed
* - Only used for ASAP requests
*/
/*@trc_desc
*bit |15..14| 13..11 | 10 | 9..6 | 5..0 |
*def | Type | Phase | Rsvd | Resched_att | Prio_inc |
*
*Phase: only if Type = 01..11
*Resched_att: only if Type = 01..11
*Prio_inc: only if Type = 01..11
*
*@trc_ref Type:
* - 00: No ASAP
* - 01: ASAP no limit
* - 10: ASAP with limit
* - 11: ASAP with limit and no parity check
*
*@trc_ref Phase:
* - 000: phase 0
* - 001: phase 1
* - 010: phase 2
* - 011: phase 3
* - 100: don-t care
*/
uint16_t asap_settings;
/// Current priority
uint8_t current_prio;
/// Latency to notify to stop the activity before next activity is notified to start (in half-slots, 0 if no stop required)
uint8_t stop_latency;
/************************************************************************************
* ISR CALLBACKS
************************************************************************************/
/// Start notification call back function
void (*cb_start)(struct sch_arb_elt_tag*);
/// Stop notification call back function
void (*cb_stop)(struct sch_arb_elt_tag*);
/// Cancel notification call back function
void (*cb_cancel)(struct sch_arb_elt_tag*);
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the Scheduling Arbiter.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void sch_arb_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Insert a new reservation in the schedule
*
* @param[in] elt Pointer to the element to be inserted
*
* @return No error if element is inserted.
****************************************************************************************
*/
uint8_t sch_arb_insert(struct sch_arb_elt_tag *elt);
/**
****************************************************************************************
* @brief Remove a reservation
*
* @param[in] elt Pointer to the element to be removed from current ptr
* @param[in] not_waiting True: activity is already started | False: may be waiting or not
*
****************************************************************************************
*/
uint8_t sch_arb_remove(struct sch_arb_elt_tag *elt, bool not_waiting);
/**
****************************************************************************************
* @brief Start of event/frame interrupt handler
*
* This function is called under interrupt when a start of event/frame interrupt is
* generated by the BLE/BT core.
*
****************************************************************************************
*/
void sch_arb_event_start_isr(void);
/**
****************************************************************************************
* @brief Software interrupt handler
*
* This function is called under interrupt when a SW interrupt is generated by the BLE/BT
* core.
*
****************************************************************************************
*/
void sch_arb_sw_isr(void);
///@} SCH_ARB
#endif // _SCH_ARB_H_
+227
View File
@@ -0,0 +1,227 @@
/**
****************************************************************************************
*
* @file SCH_PLAN.h
*
* @brief SCH_PLAN main module
*
* Copyright (C) RivieraWaves 2009-2018
*
*
****************************************************************************************
*/
#ifndef _SCH_PLAN_H_
#define _SCH_PLAN_H_
/**
****************************************************************************************
* @addtogroup SCH
* @brief Entry points of the Scheduling Planner module
*
* This module contains the primitives that allow stacks to plan periodic activities
*
* @{
****************************************************************************************
*/
#include <stdint.h> // Standard integer definitions
#include <stdbool.h> // Standard boolean definitions
#include "co_list.h" // List management functions definitions
/*
* MACROS
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/*
* DEFINITIONS
****************************************************************************************
*/
/// SCH_PLAN error codes
enum sch_plan_error
{
/// SCH_PLAN request succeed
SCH_PLAN_ERROR_OK = 0,
/// SCH_PLAN request rejected error
SCH_PLAN_ERROR_REJECTED,
/// SCH_PLAN element not found error
SCH_PLAN_ERROR_NOT_FOUND,
/// SCH_PLAN request rejected due to bandwidth full error
SCH_PLAN_ERROR_BW_FULL
};
/// SCH_PLAN mobility levels
enum sch_plan_mb_lvl
{
/// SCH_PLAN mobility level 0 (not movable)
SCH_PLAN_MB_LVL_0 = 0,
/// SCH_PLAN mobility level 1
SCH_PLAN_MB_LVL_1,
/// SCH_PLAN mobility level 2
SCH_PLAN_MB_LVL_2,
/// SCH_PLAN mobility level 3
SCH_PLAN_MB_LVL_3,
/// SCH_PLAN mobility level 4
SCH_PLAN_MB_LVL_4
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Planner element structure
struct sch_plan_elt_tag
{
/// List element for chaining in the Interval list
struct co_list_hdr hdr;
/// Move notification call back function
void (*cb_move)(uint16_t id);
/// Interval (in half-slots)
uint16_t interval;
/// Offset (in half-slots)
uint16_t offset;
/// Minimum duration (in half-slots)
uint16_t duration_min;
/// Maximum duration (in half-slots)
uint16_t duration_max;
/// Connection handle
uint16_t conhdl;
/// Reference connection handle, the primary activity on which the new activity refers to (e.g. ACL connection for a synchronous connection)
uint16_t conhdl_ref;
/// Margin to consider around the activity events, when not related to the same activity (in half-slots)
uint16_t margin;
/// Mobility level
uint8_t mobility;
};
/// API request parameters
struct sch_plan_req_param
{
/// Interval minimum requested (in half-slots)
uint16_t interval_min;
/// Interval maximum requested (in half-slots)
uint16_t interval_max;
/// Interval returned (in half-slots)
uint16_t interval;
/// Duration minimum requested (in half-slots)
uint16_t duration_min;
/// Duration maximum requested (in half-slots)
uint16_t duration_max;
/// Minimum offset requested and returned (in half-slots)
uint16_t offset_min;
/// Maximum offset requested and returned (in half-slots)
uint16_t offset_max;
/// Connection handle
uint16_t conhdl;
/// Reference connection handle, the primary activity on which the new activity refers to (e.g. ACL connection for a synchronous connection)
uint16_t conhdl_ref;
/// Margin to consider around the activity events, when not related to the same activity (in half-slots)
uint16_t margin;
/// Preferred periodicity (in half-slots)
uint8_t pref_period;
};
/// API check parameters
struct sch_plan_chk_param
{
/// Interval (in half-slots)
uint16_t interval;
/// Duration minimum requested (in half-slots)
uint16_t duration_min;
/// Offset requested (in half-slots)
uint16_t offset;
/// Connection handle
uint16_t conhdl;
/// Reference connection handle, the primary activity on which the new activity refers to (e.g. ACL connection for a synchronous connection)
uint16_t conhdl_ref;
/// Margin to consider around the activity events, when not related to the same activity (in half-slots)
uint16_t margin;
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the Scheduling Planner.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void sch_plan_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Insert the element in the planning
****************************************************************************************
*/
void sch_plan_set(struct sch_plan_elt_tag *plan_elt);
/**
****************************************************************************************
* @brief Remove the element from the planning
****************************************************************************************
*/
void sch_plan_rem(struct sch_plan_elt_tag *plan_elt);
/**
****************************************************************************************
* @brief Choose appropriate parameters for the activity
*
* @param[in|out] req_param Input parameters, modified according to the planning
*
* @return See sch_plan_error error codes
****************************************************************************************
*/
uint8_t sch_plan_req(struct sch_plan_req_param* req_param);
/**
****************************************************************************************
* @brief Check if the provided activity parameters are fitting in the planning
*
* @param[in] chk_param Input parameters
*
* @return See sch_plan_error error codes
****************************************************************************************
*/
uint8_t sch_plan_chk(struct sch_plan_chk_param* chk_param);
/**
****************************************************************************************
* @brief Shift activities related to a reference connection handle
*
* The planner updates all activities related to a reference connection handle. If a conflict results to
* the shift, it might notify one activity to move.
*
* @param[in] conhdl_ref Reference connection handle
* @param[in] shift Shift in (half-slots)
****************************************************************************************
*/
void sch_plan_shift(uint16_t conhdl_ref, int16_t shift);
///@} SCH_PLAN
#endif // _SCH_PLAN_H_
+270
View File
@@ -0,0 +1,270 @@
/**
****************************************************************************************
*
* @file sch_prog.h
*
* @brief Scheduling Programmer API
*
* Copyright (C) RivieraWaves 2009-2017
*
****************************************************************************************
*/
#ifndef SCH_PROG_H_
#define SCH_PROG_H_
/**
****************************************************************************************
* @defgroup SCH_PROG Scheduling Programmer
* @ingroup SCH
* @brief Responsible for programming BT/BLE frames.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
/*
* DEFINES
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Mode
enum SCH_FRAME_TYPE
{
SCH_PROG_BLE,
SCH_PROG_BT,
};
/// Frame type
enum SCH_FRAME_IRQ
{
/// Normal End of Event
SCH_FRAME_IRQ_EOF = 0x00,
/// End of event due to an abort
SCH_FRAME_IRQ_EOF_ABORT = 0x01,
/// SKIP Event IRQ
SCH_FRAME_IRQ_SKIP = 0x04,
/// RX ACL IRQ
SCH_FRAME_IRQ_RX = 0x02,
/// TX ACL IRQ
SCH_FRAME_IRQ_TX = 0x03,
#if (BLE_ISO_PRESENT)
/// RX ISO IRQ
SCH_FRAME_IRQ_RX_ISO = 0x05,
/// TX ISO IRQ
SCH_FRAME_IRQ_TX_ISO = 0x06,
#endif // (BLE_ISO_PRESENT)
};
#if BT_EMB_PRESENT
/// Frame type
enum SCH_BT_FRAME_TYPE
{
SCH_BT_FRAME_TYPE_NORMAL = 0x00,
SCH_BT_FRAME_TYPE_SNIFF = 0x01,
SCH_BT_FRAME_TYPE_ESCO = 0x02,
SCH_BT_FRAME_TYPE_CSB = 0x03,
SCH_BT_FRAME_TYPE_ESCO_RETX = 0x04,
};
#endif //BT_EMB_PRESENT
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback for interrupt related to the frame
*
* @param[in] timestamp Timestamp of the programmed frame (in BLE slots, based on local clock)
* @param[in] dummy Dummy value (provided by the driver when programming the frame via sch_prog_push)
* @param[in] irq_type IRQ type (0: End Of Frame | 1: RX)
****************************************************************************************
*/
typedef void (*frm_cbk_t)(uint32_t timestamp, uint32_t dummy, uint8_t irq_type);
#if BT_EMB_PRESENT
/**
****************************************************************************************
* @brief Callback for interrupt related to the clock IRQ
*
* @param[in] clock Clock when the IRQ happened
* @param[in] id Identification value
****************************************************************************************
*/
typedef void (*clk_cbk_t)(uint32_t clock, uint8_t id);
#endif //BT_EMB_PRESENT
#if BLE_EMB_PRESENT
/// Additional parameters for BLE frame
struct sch_prog_params_ble
{
/// Advertising channel type: 0x0: AE Start on Primary channel | 0x1: AE Start on Secondary channel
uint8_t ae_nps;
/// Reserved audio event (0: reTx, 1:primary)
uint8_t rsvd;
/// Isochronous event (0: normal event | 1: iso event)
uint8_t iso;
/// Start Instant Correction (SIC) bit value
uint8_t sic;
};
#endif //BLE_EMB_PRESENT
#if BT_EMB_PRESENT
/// Additional parameters for BT frame
struct sch_prog_params_bt
{
/// Frame type (0: normal | 1: sniff | 2: ESCO | 3: CSB)
uint8_t frm_type;
/// Voice channel
uint8_t vxchan;
};
#endif //BT_EMB_PRESENT
/// Parameters for a programmed frame
struct sch_prog_params
{
/// Callback for handling interrupts related to the frame
frm_cbk_t frm_cbk;
/// Timestamp (in half-slots, based on local clock) and event offset (in half-us) of the programmed frame
rwip_time_t time;
/// Bandwidth duration of the event using priority 1 (in half us)
uint32_t bandwidth;
/// Dummy value reported when an event happen during the frame or the frame is completed
uint32_t dummy;
/// Priority during duration of bandwidth
uint8_t prio_1;
/// Priority after bandwidth elapsed
uint8_t prio_2;
/// Priority after trigger conditions
uint8_t prio_3;
/// Priority when specific action occurs during the event
uint8_t pti_prio;
/// Control structure index
uint8_t cs_idx;
/// Mode (0: BLE, 1:BT)
uint8_t mode;
union
{
#if BLE_EMB_PRESENT
/// Additional parameters for BLE frame
struct sch_prog_params_ble ble;
#endif //BLE_EMB_PRESENT
#if BT_EMB_PRESENT
/// Additional parameters for BT frame
struct sch_prog_params_bt bt;
#endif //BT_EMB_PRESENT
} add;
};
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the SCH_PROG module
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void sch_prog_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Handle "RX" interrupt
*
* @param[in] et_idx Entry index that trigger the ISR (@note Valid only with 5.0 + ISO HW)
****************************************************************************************
*/
void sch_prog_rx_isr(uint8_t et_idx);
/**
****************************************************************************************
* @brief Handle FIFO interrupt
****************************************************************************************
*/
void sch_prog_fifo_isr(void);
/**
****************************************************************************************
* @brief Push a new programmed frame
*
* @param[in] params Parameters structure
****************************************************************************************
*/
void sch_prog_push(struct sch_prog_params* params);
#if BT_EMB_PRESENT
/**
****************************************************************************************
* @brief Enable the programming of an activity
*
* @param[in] clk_cbk Callback for handling interrupts related to the clock
* @param[in] id Identification value
* @param[in] sr_size Size of the sub rating pattern (in number of bits), 0 if no sub rating
* @param[in] sr_val Sub rating pattern value, representing the clock LSBs when interrupt is raised
****************************************************************************************
*/
void sch_prog_enable(clk_cbk_t clk_cbk, uint8_t id, uint8_t sr_size, uint8_t sr_val);
/**
****************************************************************************************
* @brief Disable the programming of an activity
*
* @param[in] id Identification value
****************************************************************************************
*/
void sch_prog_disable(uint8_t id);
/**
****************************************************************************************
* @brief Handle "clock" interrupt
****************************************************************************************
*/
void sch_prog_clk_isr(void);
/**
****************************************************************************************
* @brief Handle "Skip" interrupt
*
* @param[in] et_idx Entry index that trigger the ISR (@note Valid only with 5.0 + ISO HW)
****************************************************************************************
*/
void sch_prog_skip_isr(uint8_t et_idx);
/**
****************************************************************************************
* @brief Handle "End of Event" interrupt
*
* @param[in] et_idx Entry index that trigger the ISR (@note Valid only with 5.0 + ISO HW)
****************************************************************************************
*/
void sch_prog_end_isr(uint8_t et_idx);
#endif //BT_EMB_PRESENT
/// @} SCH_PROG
#endif // SCH_PROG_H_
+181
View File
@@ -0,0 +1,181 @@
/**
****************************************************************************************
*
* @file sch_slice.h
*
* @brief LD Scheduling Parameters API
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef SCH_SLICE_H_
#define SCH_SLICE_H_
/**
****************************************************************************************
* @defgroup SCHSLICE Scheduling parameters
* @ingroup SCH
* @brief Responsible for selecting the optimal scheduling parameters.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
/*
* DEFINES
****************************************************************************************
*/
/// Undefined BT clock value
#define SCH_CLOCK_UNDEF 0xFFFFFFFF
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Activity type
enum activity_type
{
#if BLE_EMB_PRESENT
BLE_SCAN,
BLE_INIT,
BLE_HDC_ADV,
BLE_PER_ADV,
BLE_CON,
#endif //BLE_EMB_PRESENT
#if BT_EMB_PRESENT
BT_INQ,
BT_PAGE,
BT_ISCAN,
BT_PSCAN,
BT_SSCAN,
BT_SNIFF,
BT_SCO,
#endif //BT_EMB_PRESENT
};
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/// SCH SLICE parameters structure
struct sch_slice_params_tag
{
/// End of ongoing foreground activity (inq, page, HDC adv) (in BT half-slot clock, SCH_CLOCK_UNDEF if inactive)
uint32_t fg_end_ts;
/// Scan / Inq / Page event duration (in half-us)
uint16_t scan_evt_dur;
#if BT_EMB_PRESENT
/// ACL event duration size (in half-us)
uint16_t acl_evt_dur;
/// SCO retx are allowed to reserve
bool sco_retx_allowed;
#endif //BT_EMB_PRESENT
};
/*
* VARIABLE DECLARATION
****************************************************************************************
*/
/// SCH SLICE parameters variable
extern struct sch_slice_params_tag sch_slice_params;
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the SCH_SLICE module
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void sch_slice_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Add a background activity
*
* @param[in] type Activity type (@see @enum activity_type)
****************************************************************************************
*/
void sch_slice_bg_add(uint8_t type);
/**
****************************************************************************************
* @brief Remove a background activity
*
* @param[in] type Activity type (@see @enum activity_type)
****************************************************************************************
*/
void sch_slice_bg_remove(uint8_t type);
/**
****************************************************************************************
* @brief Add a foreground activity
*
* @param[in] type Activity type (@see @enum activity_type)
* @param[in] end_ts Timestamp of the activity end (in half-slot clock)
****************************************************************************************
*/
void sch_slice_fg_add(uint8_t type, uint32_t end_ts);
/**
****************************************************************************************
* @brief Remove a foreground activity
*
* @param[in] type Activity type (@see @enum activity_type)
****************************************************************************************
*/
void sch_slice_fg_remove(uint8_t type);
/**
****************************************************************************************
* @brief Add a periodic activity
*
* @param[in] type Activity type (@see @enum activity_type)
* @param[in] id Identifier of the activity (depending on the activity type)
* @param[in] intv Interval (in half-slot)
* @param[in] duration Events duration (in half-us)
* @param[in] retx Potential retransmissions (applicable to SCO only)
****************************************************************************************
*/
void sch_slice_per_add(uint8_t type, uint8_t id, uint32_t intv, uint16_t duration, bool retx);
/**
****************************************************************************************
* @brief Remove a periodic activity
*
* @param[in] type Activity type (@see @enum activity_type)
* @param[in] id Identifier of the activity (depending on the activity type)
****************************************************************************************
*/
void sch_slice_per_remove(uint8_t type, uint8_t id);
/// @} SCHSLICE
#endif // SCH_SLICE_H_