mirror of https://github.com/ARMmbed/mbed-os.git
to be commented
parent
4a38ec8b83
commit
2b9de59387
|
@ -4,10 +4,10 @@ LR_IROM1 0x21000 0x00DF000 {
|
|||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM0 0x20002EF8 UNINIT 0x000000F4 { ;no init section
|
||||
RW_IRAM0 0x20002EF8 UNINIT 0x000000F8 { ;no init section
|
||||
*(noinit)
|
||||
}
|
||||
RW_IRAM1 0x20002FEC 0x0003D014 {
|
||||
RW_IRAM1 0x20002FF0 0x0003D010 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2312,7 +2312,7 @@
|
|||
// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
|
||||
//==========================================================
|
||||
#ifndef TWI_ENABLED
|
||||
#define TWI_ENABLED 0
|
||||
#define TWI_ENABLED 1
|
||||
#endif
|
||||
#if TWI_ENABLED
|
||||
// <o> TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
|
||||
|
@ -2779,7 +2779,7 @@
|
|||
// <e> APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler
|
||||
//==========================================================
|
||||
#ifndef APP_SCHEDULER_ENABLED
|
||||
#define APP_SCHEDULER_ENABLED 0
|
||||
#define APP_SCHEDULER_ENABLED 1
|
||||
#endif
|
||||
#if APP_SCHEDULER_ENABLED
|
||||
// <q> APP_SCHEDULER_WITH_PAUSE - Enabling pause feature
|
||||
|
@ -2802,7 +2802,7 @@
|
|||
// <e> APP_TIMER_ENABLED - app_timer - Application timer functionality
|
||||
//==========================================================
|
||||
#ifndef APP_TIMER_ENABLED
|
||||
#define APP_TIMER_ENABLED 0
|
||||
#define APP_TIMER_ENABLED 1
|
||||
#endif
|
||||
#if APP_TIMER_ENABLED
|
||||
// <q> APP_TIMER_WITH_PROFILER - Enable app_timer profiling
|
||||
|
@ -2835,7 +2835,7 @@
|
|||
// <e> APP_UART_ENABLED - app_uart - UART driver
|
||||
//==========================================================
|
||||
#ifndef APP_UART_ENABLED
|
||||
#define APP_UART_ENABLED 0
|
||||
#define APP_UART_ENABLED 1
|
||||
#endif
|
||||
#if APP_UART_ENABLED
|
||||
// <o> APP_UART_DRIVER_INSTANCE - UART instance used
|
||||
|
@ -2860,14 +2860,14 @@
|
|||
|
||||
|
||||
#ifndef APP_USBD_CLASS_HID_ENABLED
|
||||
#define APP_USBD_CLASS_HID_ENABLED 0
|
||||
#define APP_USBD_CLASS_HID_ENABLED 1
|
||||
#endif
|
||||
|
||||
// <q> APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic
|
||||
|
||||
|
||||
#ifndef APP_USBD_HID_GENERIC_ENABLED
|
||||
#define APP_USBD_HID_GENERIC_ENABLED 0
|
||||
#define APP_USBD_HID_GENERIC_ENABLED 1
|
||||
#endif
|
||||
|
||||
// <q> APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard
|
||||
|
@ -2881,7 +2881,7 @@
|
|||
|
||||
|
||||
#ifndef APP_USBD_HID_MOUSE_ENABLED
|
||||
#define APP_USBD_HID_MOUSE_ENABLED 0
|
||||
#define APP_USBD_HID_MOUSE_ENABLED 1
|
||||
#endif
|
||||
|
||||
// <q> BUTTON_ENABLED - app_button - buttons handling module
|
||||
|
|
|
@ -601,6 +601,27 @@ ret_code_t nrf_drv_spi_xfer(nrf_drv_spi_t const * const p_instance,
|
|||
return err_code;
|
||||
)
|
||||
}
|
||||
|
||||
// modification for mbed-os
|
||||
#if __MBED__
|
||||
void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance)
|
||||
{
|
||||
spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
CODE_FOR_SPIM
|
||||
(
|
||||
nrf_spim_task_trigger(p_instance, NRF_SPIM_TASK_STOP);
|
||||
while (!nrf_spim_event_check(p_instance, NRF_SPIM_EVENT_STOPPED)) {}
|
||||
p_cb->transfer_in_progress = false;
|
||||
)
|
||||
CODE_FOR_SPI
|
||||
(
|
||||
p_cb->abort = true;
|
||||
)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SPIM_IN_USE
|
||||
static void irq_handler_spim(NRF_SPIM_Type * p_spim, spi_control_block_t * p_cb)
|
||||
{
|
||||
|
|
|
@ -397,6 +397,11 @@ uint32_t nrf_drv_spi_start_task_get(nrf_drv_spi_t const * p_instance);
|
|||
*/
|
||||
uint32_t nrf_drv_spi_end_event_get(nrf_drv_spi_t const * p_instance);
|
||||
|
||||
// modification for mbed-os
|
||||
#if __MBED__
|
||||
void nrf_drv_spi_abort(nrf_drv_spi_t const * p_instance);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -683,7 +683,18 @@ __STATIC_INLINE ret_code_t twi_xfer(twi_control_block_t * p_cb,
|
|||
}
|
||||
#endif
|
||||
|
||||
// modification for mbed-os
|
||||
#if __MBED__
|
||||
bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance)
|
||||
{
|
||||
twi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
return p_cb->busy;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TWIM_IN_USE
|
||||
|
||||
|
||||
__STATIC_INLINE void twim_list_enable_handle(NRF_TWIM_Type * p_twim, uint32_t flags)
|
||||
{
|
||||
if (NRF_DRV_TWI_FLAG_TX_POSTINC & flags)
|
||||
|
|
|
@ -380,6 +380,19 @@ ret_code_t nrf_drv_twi_xfer(nrf_drv_twi_t const * p_instance,
|
|||
nrf_drv_twi_xfer_desc_t const * p_xfer_desc,
|
||||
uint32_t flags);
|
||||
|
||||
// modification for mbed-os
|
||||
#if __MBED__
|
||||
/**
|
||||
* @brief Function for checking the TWI driver state.
|
||||
*
|
||||
* @param[in] p_instance TWI instance.
|
||||
*
|
||||
* @retval true If the TWI driver is currently busy performing a transfer.
|
||||
* @retval false If the TWI driver is ready for a new transfer.
|
||||
*/
|
||||
bool nrf_drv_twi_is_busy(nrf_drv_twi_t const * p_instance);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for getting the transferred data count.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
* the file.
|
||||
*
|
||||
*/
|
||||
#ifndef __MBED_CMSIS_RTOS_CM
|
||||
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_TIMER)
|
||||
#include "app_timer.h"
|
||||
|
@ -1048,3 +1050,4 @@ uint8_t app_timer_op_queue_utilization_get(void)
|
|||
}
|
||||
#endif
|
||||
#endif //NRF_MODULE_ENABLED(APP_TIMER)
|
||||
#endif // __MBED_CMSIS_RTOS_CM
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,230 +0,0 @@
|
|||
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_TIMER)
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
|
||||
#include "app_timer.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "nrf.h"
|
||||
#include "app_error.h"
|
||||
|
||||
/* Check if RTC FreeRTOS version is used */
|
||||
#if configTICK_SOURCE != FREERTOS_USE_RTC
|
||||
#error app_timer in FreeRTOS variant have to be used with RTC tick source configuration. Default configuration have to be used in other case.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Waiting time for the timer queue
|
||||
*
|
||||
* Number of system ticks to wait for the timer queue to put the message.
|
||||
* It is strongly recommended to set this to the value bigger than 1.
|
||||
* In other case if timer message queue is full - any operation on timer may fail.
|
||||
* @note
|
||||
* Timer functions called from interrupt context would never wait.
|
||||
*/
|
||||
#define APP_TIMER_WAIT_FOR_QUEUE 2
|
||||
|
||||
/**@brief This structure keeps information about osTimer.*/
|
||||
typedef struct
|
||||
{
|
||||
void * argument;
|
||||
TimerHandle_t osHandle;
|
||||
app_timer_timeout_handler_t func;
|
||||
/**
|
||||
* This member is to make sure that timer function is only called if timer is running.
|
||||
* FreeRTOS may have timer running even after stop function is called,
|
||||
* because it processes commands in Timer task and stopping function only puts command into the queue. */
|
||||
bool active;
|
||||
}app_timer_info_t;
|
||||
|
||||
/**
|
||||
* @brief Prescaler that was set by the user
|
||||
*
|
||||
* In FreeRTOS version of app_timer the prescaler setting is constant and done by the operating system.
|
||||
* But the application expect the prescaler to be set according to value given in setup and then
|
||||
* calculate required ticks using this value.
|
||||
* For compatibility we remember the value set and use it for recalculation of required timer setting.
|
||||
*/
|
||||
static uint32_t m_prescaler;
|
||||
|
||||
/* Check if freeRTOS timers are activated */
|
||||
#if configUSE_TIMERS == 0
|
||||
#error app_timer for freeRTOS requires configUSE_TIMERS option to be activated.
|
||||
#endif
|
||||
|
||||
/* Check if app_timer_t variable type can held our app_timer_info_t structure */
|
||||
STATIC_ASSERT(sizeof(app_timer_info_t) <= sizeof(app_timer_t));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal callback function for the system timer
|
||||
*
|
||||
* Internal function that is called from the system timer.
|
||||
* It gets our parameter from timer data and sends it to user function.
|
||||
* @param[in] xTimer Timer handler
|
||||
*/
|
||||
static void app_timer_callback(TimerHandle_t xTimer)
|
||||
{
|
||||
app_timer_info_t * pinfo = (app_timer_info_t*)(pvTimerGetTimerID(xTimer));
|
||||
ASSERT(pinfo->osHandle == xTimer);
|
||||
ASSERT(pinfo->func != NULL);
|
||||
|
||||
if (pinfo->active)
|
||||
pinfo->func(pinfo->argument);
|
||||
}
|
||||
|
||||
|
||||
uint32_t app_timer_init(uint32_t prescaler,
|
||||
uint8_t op_queues_size,
|
||||
void * p_buffer,
|
||||
app_timer_evt_schedule_func_t evt_schedule_func)
|
||||
{
|
||||
UNUSED_PARAMETER(op_queues_size);
|
||||
UNUSED_PARAMETER(p_buffer);
|
||||
UNUSED_PARAMETER(evt_schedule_func);
|
||||
|
||||
m_prescaler = prescaler + 1;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t app_timer_create(app_timer_id_t const * p_timer_id,
|
||||
app_timer_mode_t mode,
|
||||
app_timer_timeout_handler_t timeout_handler)
|
||||
{
|
||||
app_timer_info_t * pinfo = (app_timer_info_t*)(*p_timer_id);
|
||||
uint32_t err_code = NRF_SUCCESS;
|
||||
unsigned long timer_mode;
|
||||
|
||||
if ((timeout_handler == NULL) || (p_timer_id == NULL))
|
||||
{
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (pinfo->active)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (pinfo->osHandle == NULL)
|
||||
{
|
||||
/* New timer is created */
|
||||
memset(pinfo, 0, sizeof(app_timer_info_t));
|
||||
|
||||
if (mode == APP_TIMER_MODE_SINGLE_SHOT)
|
||||
timer_mode = pdFALSE;
|
||||
else
|
||||
timer_mode = pdTRUE;
|
||||
|
||||
pinfo->func = timeout_handler;
|
||||
pinfo->osHandle = xTimerCreate(" ", 1000, timer_mode, pinfo, app_timer_callback);
|
||||
|
||||
if (pinfo->osHandle == NULL)
|
||||
err_code = NRF_ERROR_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Timer cannot be reinitialized using FreeRTOS API */
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
|
||||
{
|
||||
app_timer_info_t * pinfo = (app_timer_info_t*)(timer_id);
|
||||
TimerHandle_t hTimer = pinfo->osHandle;
|
||||
uint32_t rtc_prescaler = portNRF_RTC_REG->PRESCALER + 1;
|
||||
/* Get back the microseconds to wait */
|
||||
uint32_t timeout_corrected = ROUNDED_DIV(timeout_ticks * m_prescaler, rtc_prescaler);
|
||||
|
||||
if (hTimer == NULL)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
if (pinfo->active && (xTimerIsTimerActive(hTimer) != pdFALSE))
|
||||
{
|
||||
// Timer already running - exit silently
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
pinfo->argument = p_context;
|
||||
|
||||
if (__get_IPSR() != 0)
|
||||
{
|
||||
BaseType_t yieldReq = pdFALSE;
|
||||
if (xTimerChangePeriodFromISR(hTimer, timeout_corrected, &yieldReq) != pdPASS)
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
if ( xTimerStartFromISR(hTimer, &yieldReq) != pdPASS )
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
portYIELD_FROM_ISR(yieldReq);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xTimerChangePeriod(hTimer, timeout_corrected, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS)
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
if (xTimerStart(hTimer, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS)
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
pinfo->active = true;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t app_timer_stop(app_timer_id_t timer_id)
|
||||
{
|
||||
app_timer_info_t * pinfo = (app_timer_info_t*)(timer_id);
|
||||
TimerHandle_t hTimer = pinfo->osHandle;
|
||||
if (hTimer == NULL)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (__get_IPSR() != 0)
|
||||
{
|
||||
BaseType_t yieldReq = pdFALSE;
|
||||
if (xTimerStopFromISR(timer_id, &yieldReq) != pdPASS)
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
portYIELD_FROM_ISR(yieldReq);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xTimerStop(timer_id, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS)
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
pinfo->active = false;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
#endif //NRF_MODULE_ENABLED(APP_TIMER)
|
|
@ -9,7 +9,8 @@
|
|||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __MBED_CMSIS_RTOS_CM
|
||||
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_TIMER)
|
||||
#include "app_timer.h"
|
||||
|
@ -254,3 +255,5 @@ uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to,
|
|||
return NRF_SUCCESS;
|
||||
}
|
||||
#endif //NRF_MODULE_ENABLED(APP_TIMER)
|
||||
|
||||
#endif // __MBED_CMSIS_RTOS_CM
|
||||
|
|
Loading…
Reference in New Issue