simplelink: dpl: implement some dpl functions for the RF driver

Implementing a few functions that are necessary for the RF driver
to build:

- ClockP_getTimeout
- ClockP_isActive
- ClockP_destruct
- SemaphoreP_construct
- SemaphoreP_constructBinary
- SemaphoreP_destruct
- HwiP_post
- HwiP_setFunc
- HwiP_destruct
This commit is contained in:
Christopher Friedt 2019-10-20 15:41:28 -04:00 committed by Kumar Gala
parent e14693f475
commit e8f58c6564
6 changed files with 148 additions and 1 deletions

View File

@ -68,9 +68,11 @@ elseif(CONFIG_HAS_CC13X2_CC26X2_SDK)
source/ti/drivers/utils/List.c
source/ti/drivers/rf/RFCC26X2_multiMode.c
kernel/zephyr/dpl/config.c
kernel/zephyr/dpl/ClockP_zephyr.c
kernel/zephyr/dpl/HwiP_zephyr.c
kernel/zephyr/dpl/SwiP_zephyr.c
kernel/zephyr/dpl/SemaphoreP_zephyr.c
)
if(CONFIG_SOC_CC1352R)

View File

@ -9,6 +9,8 @@
#include <kernel/zephyr/dpl/dpl.h>
#include <ti/drivers/dpl/ClockP.h>
#include "stubs.h"
/*
* ClockP_STRUCT_SIZE in ClockP.h must be updated to match the size of this
* struct
@ -19,6 +21,7 @@ typedef struct _ClockP_Obj {
uintptr_t arg;
uint32_t timeout;
uint32_t period;
bool active;
} ClockP_Obj;
static void expiry_fxn(struct k_timer *timer_id)
@ -44,6 +47,7 @@ ClockP_Handle ClockP_construct(ClockP_Struct *handle, ClockP_Fxn clockFxn,
obj->arg = params->arg;
obj->period = params->period * ClockP_getSystemTickPeriod() / 1000;
obj->timeout = timeout;
obj->active = false;
k_timer_init(&obj->timer, expiry_fxn, NULL);
k_timer_user_data_set(&obj->timer, obj);
@ -58,9 +62,10 @@ ClockP_Handle ClockP_construct(ClockP_Struct *handle, ClockP_Fxn clockFxn,
/*
* ======== ClockP_getSystemTickPeriod ========
*/
uint32_t ClockP_tickPeriod = (1000000 / CONFIG_SYS_CLOCK_TICKS_PER_SEC);
uint32_t ClockP_getSystemTickPeriod()
{
return (1000000 / CONFIG_SYS_CLOCK_TICKS_PER_SEC);
return ClockP_tickPeriod;
}
uint32_t ClockP_getSystemTicks()
@ -99,6 +104,7 @@ void ClockP_start(ClockP_Handle handle)
k_timer_start(&obj->timer, obj->timeout * 1000 /
CONFIG_SYS_CLOCK_TICKS_PER_SEC, obj->period);
obj->active = true;
}
/*
@ -109,9 +115,42 @@ void ClockP_stop(ClockP_Handle handle)
ClockP_Obj *obj = (ClockP_Obj *)handle;
k_timer_stop(&obj->timer);
obj->active = false;
}
/*
* ======== ClockP_usleep ========
*/
void ClockP_usleep(uint32_t usec)
{
k_sleep((s32_t)usec);
}
/*
* ======== ClockP_getTimeout ========
*/
uint32_t ClockP_getTimeout(ClockP_Handle handle) {
ClockP_Obj *obj = (ClockP_Obj *)handle;
return k_timer_remaining_get(&obj->timer) * CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000;
}
/*
* ======== ClockP_isActive ========
*/
bool ClockP_isActive(ClockP_Handle handle) {
ClockP_Obj *obj = (ClockP_Obj *)handle;
return obj->active;
}
void ClockP_destruct(ClockP_Struct *clockP)
{
ClockP_Obj *obj = (ClockP_Obj *)clockP->data;
obj->clock_fxn = NULL;
obj->arg = 0;
obj->period = 0;
obj->timeout = 0;
obj->active = false;
k_timer_stop(&obj->timer);
}

View File

@ -18,6 +18,7 @@
#endif
#include <driverlib/interrupt.h>
#include "stubs.h"
/*
* IRQ_CONNECT requires we know the ISR signature and argument
@ -219,3 +220,27 @@ void HwiP_restore(uintptr_t key)
{
irq_unlock(key);
}
void HwiP_post(int interruptNum) {
ARG_UNUSED(interruptNum);
STUB("");
}
void HwiP_setFunc(HwiP_Handle hwiP, HwiP_Fxn fxn, uintptr_t arg) {
ARG_UNUSED(hwiP);
ARG_UNUSED(fxn);
ARG_UNUSED(arg);
STUB("");
}
void HwiP_destruct(HwiP_Struct *hwiP)
{
HwiP_Obj *obj = (HwiP_Obj *)hwiP->data;
int interruptNum = obj->intNum;
irq_disable(interruptNum - 16);
obj->cb->cb = NULL;
obj->cb->arg = (uintptr_t)NULL;
obj->cb = NULL;
}

View File

@ -9,6 +9,8 @@
#include <kernel/zephyr/dpl/dpl.h>
#include <ti/drivers/dpl/SemaphoreP.h>
#include "stubs.h"
/*
* Zephyr kernel object pools:
*
@ -138,3 +140,40 @@ void SemaphoreP_post(SemaphoreP_Handle handle)
{
k_sem_give((struct k_sem *)handle);
}
SemaphoreP_Handle SemaphoreP_construct(SemaphoreP_Struct *handle,
unsigned int count, SemaphoreP_Params *params)
{
unsigned int limit = UINT_MAX;
struct k_sem *sem;
if (params) {
limit = (params->mode == SemaphoreP_Mode_BINARY) ?
1 : UINT_MAX;
}
sem = (struct k_sem *)handle;
if (sem) {
k_sem_init(sem, 0, limit);
}
return (SemaphoreP_Handle)sem;
}
SemaphoreP_Handle SemaphoreP_constructBinary(SemaphoreP_Struct *handle, unsigned int count) {
SemaphoreP_Params params;
SemaphoreP_Params_init(&params);
params.mode = SemaphoreP_Mode_BINARY;
return (SemaphoreP_construct(handle, count, &params));
}
void SemaphoreP_destruct(SemaphoreP_Struct *semP) {
struct k_sem *sem;
sem = (struct k_sem *)semP->data;
if (sem) {
k_sem_reset(sem);
}
}

View File

@ -0,0 +1,34 @@
#include <stdbool.h>
#include <stdint.h>
#include <zephyr.h>
#include "stubs.h"
#ifdef CONFIG_HAS_CC13X2_CC26X2_SDK
#include "ti/devices/cc13x2_cc26x2/driverlib/interrupt.h"
#include "ti/drivers/power/PowerCC26X2.h"
#endif /* CONFIG_HAS_CC13X2_CC26X2_SDK */
#ifdef CONFIG_SOC_CC1352R
#define DeviceFamily_CC13X2
#endif /* CONFIG_SOC_CC1352R */
#ifdef CONFIG_SOC_CC2652R
#define DeviceFamily_CC26X2
#endif /* CONFIG_SOC_CC2652R */
#include "ti/drivers/rf/RF.h"
#ifdef CONFIG_HAS_CC13X2_CC26X2_SDK
const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
.hwiPriority = INT_PRI_LEVEL7, // Lowest HWI priority: INT_PRI_LEVEL7
// Highest HWI priority: INT_PRI_LEVEL1
.swiPriority = 0, // Lowest SWI priority: 0
// Highest SWI priority: Swi.numPriorities - 1
.xoscHfAlwaysNeeded = true // Power driver always starts XOSC-HF: true
// RF driver will request XOSC-HF if needed: false
};
#endif /* CONFIG_HAS_CC13X2_CC26X2_SDK */

View File

@ -0,0 +1,8 @@
#ifndef STUBS_H_
#define STUBS_H_
#include <zephyr.h>
#define STUB(fmt, args...) printk("%s(): %d: STUB: " fmt "\n", __func__, __LINE__, ##args)
#endif /* STUBS_H_ */