ext: simplelink: update dpl to support TI Power manager module
This commit updates the dpl layer for Zephyr to support the Power manager module on the CC13x2/CC26x2 family of devices. Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
This commit is contained in:
parent
4a893817e8
commit
8df649b823
|
@ -69,6 +69,7 @@ elseif(CONFIG_HAS_CC13X2_CC26X2_SDK)
|
|||
|
||||
kernel/zephyr/dpl/ClockP_zephyr.c
|
||||
kernel/zephyr/dpl/HwiP_zephyr.c
|
||||
kernel/zephyr/dpl/SwiP_zephyr.c
|
||||
)
|
||||
|
||||
if(CONFIG_SOC_CC1352R)
|
||||
|
|
|
@ -9,11 +9,108 @@
|
|||
#include <kernel/zephyr/dpl/dpl.h>
|
||||
#include <ti/drivers/dpl/ClockP.h>
|
||||
|
||||
/*
|
||||
* ClockP_STRUCT_SIZE in ClockP.h must be updated to match the size of this
|
||||
* struct
|
||||
*/
|
||||
typedef struct _ClockP_Obj {
|
||||
struct k_timer timer;
|
||||
ClockP_Fxn clock_fxn;
|
||||
uintptr_t arg;
|
||||
uint32_t timeout;
|
||||
uint32_t period;
|
||||
} ClockP_Obj;
|
||||
|
||||
static void expiry_fxn(struct k_timer *timer_id)
|
||||
{
|
||||
ClockP_Obj *obj = (ClockP_Obj *)k_timer_user_data_get(timer_id);
|
||||
|
||||
obj->clock_fxn(obj->arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_construct ========
|
||||
*/
|
||||
ClockP_Handle ClockP_construct(ClockP_Struct *handle, ClockP_Fxn clockFxn,
|
||||
uint32_t timeout, ClockP_Params *params)
|
||||
{
|
||||
ClockP_Obj *obj = (ClockP_Obj *)handle;
|
||||
|
||||
if (handle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obj->clock_fxn = clockFxn;
|
||||
obj->arg = params->arg;
|
||||
obj->period = params->period * ClockP_getSystemTickPeriod() / 1000;
|
||||
obj->timeout = timeout;
|
||||
|
||||
k_timer_init(&obj->timer, expiry_fxn, NULL);
|
||||
k_timer_user_data_set(&obj->timer, obj);
|
||||
|
||||
if (params->startFlag) {
|
||||
ClockP_start(obj);
|
||||
}
|
||||
|
||||
return ((ClockP_Handle)handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_getSystemTickPeriod ========
|
||||
*/
|
||||
uint32_t ClockP_getSystemTickPeriod()
|
||||
{
|
||||
return (1000000 / CONFIG_SYS_CLOCK_TICKS_PER_SEC);
|
||||
}
|
||||
|
||||
uint32_t ClockP_getSystemTicks()
|
||||
{
|
||||
return (uint32_t)z_ms_to_ticks(k_uptime_get_32());
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_Params_init ========
|
||||
*/
|
||||
void ClockP_Params_init(ClockP_Params *params)
|
||||
{
|
||||
params->arg = 0;
|
||||
params->startFlag = false;
|
||||
params->period = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_setTimeout ========
|
||||
*/
|
||||
void ClockP_setTimeout(ClockP_Handle handle, uint32_t timeout)
|
||||
{
|
||||
ClockP_Obj *obj = (ClockP_Obj *)handle;
|
||||
|
||||
obj->timeout = timeout;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_start ========
|
||||
*/
|
||||
void ClockP_start(ClockP_Handle handle)
|
||||
{
|
||||
ClockP_Obj *obj = (ClockP_Obj *)handle;
|
||||
|
||||
__ASSERT_NO_MSG(obj->timeout > (UINT32_MAX / 1000));
|
||||
|
||||
k_timer_start(&obj->timer, obj->timeout * 1000 /
|
||||
CONFIG_SYS_CLOCK_TICKS_PER_SEC, obj->period);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ClockP_stop ========
|
||||
*/
|
||||
void ClockP_stop(ClockP_Handle handle)
|
||||
{
|
||||
ClockP_Obj *obj = (ClockP_Obj *)handle;
|
||||
|
||||
k_timer_stop(&obj->timer);
|
||||
}
|
||||
|
||||
void ClockP_usleep(uint32_t usec)
|
||||
{
|
||||
k_sleep((s32_t)usec);
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
#include <inc/hw_types.h>
|
||||
#include <inc/hw_ints.h>
|
||||
#include <driverlib/rom.h>
|
||||
#if defined(CONFIG_SOC_SERIES_CC32XX)
|
||||
#include <driverlib/rom_map.h>
|
||||
#endif
|
||||
#include <driverlib/interrupt.h>
|
||||
|
||||
|
||||
/*
|
||||
* IRQ_CONNECT requires we know the ISR signature and argument
|
||||
* at build time; whereas SimpleLink plugs the interrupts
|
||||
|
@ -28,11 +31,6 @@ struct sl_isr_args
|
|||
uintptr_t arg;
|
||||
};
|
||||
|
||||
static struct sl_isr_args sl_UDMA_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_UDMAERR_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_NWPIC_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_LSPI_cb = {NULL, 0};
|
||||
|
||||
static void sl_isr(void *isr_arg)
|
||||
{
|
||||
HwiP_Fxn cb = ((struct sl_isr_args *)isr_arg)->cb;
|
||||
|
@ -44,6 +42,12 @@ static void sl_isr(void *isr_arg)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_CC32XX)
|
||||
static struct sl_isr_args sl_UDMA_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_UDMAERR_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_NWPIC_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_LSPI_cb = {NULL, 0};
|
||||
|
||||
/* Must hardcode the IRQ for IRQ_CONNECT macro. Must be <= CONFIG_NUM_IRQS.*/
|
||||
#define EXCEPTION_UDMA 46 /* == INT_UDMA (62) - 16 */
|
||||
#define EXCEPTION_UDMAERR 47 /* == INT_UDMAERR (63) - 16 */
|
||||
|
@ -122,6 +126,59 @@ void HwiP_delete(HwiP_Handle handle)
|
|||
|
||||
irq_disable(interruptNum - 16);
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_CC13X2_CC26X2)
|
||||
typedef struct _HwiP_Obj {
|
||||
uint32_t intNum;
|
||||
} HwiP_Obj;
|
||||
|
||||
static struct sl_isr_args sl_OSC_COMB_cb = {NULL, 0};
|
||||
static struct sl_isr_args sl_AUX_COMB_cb = {NULL, 0};
|
||||
|
||||
/*
|
||||
* ======== HwiP_construct ========
|
||||
*/
|
||||
HwiP_Handle HwiP_construct(HwiP_Struct *handle, int interruptNum,
|
||||
HwiP_Fxn hwiFxn, HwiP_Params *params)
|
||||
{
|
||||
HwiP_Obj *obj = (HwiP_Obj *)handle;
|
||||
uintptr_t arg = 0;
|
||||
|
||||
if (handle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (params) {
|
||||
arg = params->arg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Currently only support INT_OSC_COMB and INT_AUX_COMB
|
||||
*/
|
||||
__ASSERT(INT_OSC_COMB == interruptNum || INT_AUX_COMB == interruptNum,
|
||||
"Unexpected interruptNum: %d\r\n",
|
||||
interruptNum);
|
||||
|
||||
switch(interruptNum) {
|
||||
case INT_OSC_COMB:
|
||||
sl_OSC_COMB_cb.cb = hwiFxn;
|
||||
sl_OSC_COMB_cb.arg = arg;
|
||||
IRQ_CONNECT(INT_OSC_COMB - 16, 6, sl_isr, &sl_OSC_COMB_cb, 0);
|
||||
break;
|
||||
case INT_AUX_COMB:
|
||||
sl_AUX_COMB_cb.cb = hwiFxn;
|
||||
sl_AUX_COMB_cb.arg = arg;
|
||||
IRQ_CONNECT(INT_AUX_COMB - 16, 6, sl_isr, &sl_AUX_COMB_cb, 0);
|
||||
break;
|
||||
default:
|
||||
return(NULL);
|
||||
}
|
||||
irq_enable(interruptNum - 16);
|
||||
|
||||
obj->intNum = interruptNum;
|
||||
|
||||
return (HwiP_Handle)handle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void HwiP_Params_init(HwiP_Params *params)
|
||||
{
|
||||
|
@ -132,7 +189,11 @@ void HwiP_Params_init(HwiP_Params *params)
|
|||
/* Zephyr has no functions for clearing an interrupt, so use driverlib: */
|
||||
void HwiP_clearInterrupt(int interruptNum)
|
||||
{
|
||||
#if defined(CONFIG_SOC_SERIES_CC13X2_CC26X2)
|
||||
IntPendClear((unsigned long)interruptNum);
|
||||
#elif defined(CONFIG_SOC_SERIES_CC32XX)
|
||||
MAP_IntPendClear((unsigned long)interruptNum);
|
||||
#endif
|
||||
}
|
||||
|
||||
void HwiP_enableInterrupt(int interruptNum)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Texas Instruments Incorporated
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
#include <ti/drivers/dpl/SwiP.h>
|
||||
|
||||
|
||||
/*
|
||||
* ======== SwiP_disable ========
|
||||
*/
|
||||
uintptr_t SwiP_disable(void)
|
||||
{
|
||||
k_sched_lock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== SwiP_restore ========
|
||||
*/
|
||||
void SwiP_restore(uintptr_t key)
|
||||
{
|
||||
ARG_UNUSED(key);
|
||||
k_sched_unlock();
|
||||
}
|
|
@ -65,14 +65,24 @@ extern "C" {
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
/*!
|
||||
* @brief Prototype for a ClockP function.
|
||||
*/
|
||||
typedef void (*ClockP_Fxn)(uintptr_t arg);
|
||||
|
||||
/*!
|
||||
* @brief Number of bytes greater than or equal to the size of any RTOS
|
||||
* ClockP object.
|
||||
*
|
||||
* nortos: 32 (biggest of the HW-specific ClockP instance structs)
|
||||
* SysBIOS: 36
|
||||
* Zephyr: Modified to match size of ClockP_Obj
|
||||
*/
|
||||
#define ClockP_STRUCT_SIZE (36)
|
||||
#define ClockP_STRUCT_SIZE (sizeof(struct k_timer) + \
|
||||
sizeof(ClockP_Fxn) + sizeof(uintptr_t) + \
|
||||
sizeof(uint32_t) * 2)
|
||||
|
||||
/*!
|
||||
* @brief ClockP structure.
|
||||
|
@ -114,11 +124,6 @@ typedef void *ClockP_Handle;
|
|||
|
||||
extern uint32_t ClockP_tickPeriod;
|
||||
|
||||
/*!
|
||||
* @brief Prototype for a ClockP function.
|
||||
*/
|
||||
typedef void (*ClockP_Fxn)(uintptr_t arg);
|
||||
|
||||
/*!
|
||||
* @brief Basic ClockP Parameters
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue