mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2026-08-18 18:18:54 +08:00
Added Safe interrupt demo (#685)
Add project to be used for safer interrupts
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include"queue.h"
|
||||
|
||||
/* Interface includes. */
|
||||
#include "interrupt_handler_task.h"
|
||||
|
||||
/**
|
||||
* @brief Time to block while waiting for a interrupt request on the interrupt queue.
|
||||
*/
|
||||
#define USER_IRQ_RECEIVE_TIMEOUT ( pdMS_TO_TICKS( 1000 ) )
|
||||
|
||||
void vInterruptHandlerTask( void * pvParams )
|
||||
{
|
||||
BaseType_t xStatus;
|
||||
UserIrqRequest_t xIrqRequest;
|
||||
QueueHandle_t xInterruptQueueHandle = ( QueueHandle_t ) pvParams;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
xStatus = xQueueReceive( xInterruptQueueHandle,
|
||||
&( xIrqRequest ),
|
||||
USER_IRQ_RECEIVE_TIMEOUT );
|
||||
if ( xStatus != pdTRUE )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If a valid IRQ request is received, invoke the corresponding handler
|
||||
* function. */
|
||||
xIrqRequest.xHandlerFunction( xIrqRequest.ulData );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef INTERRUPT_HANDLER_TASK_H_
|
||||
#define INTERRUPT_HANDLER_H_
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* The interrupt handler task serves user IRQ requests sent to the interrupt
|
||||
* queue. A user IRQ request comprises of the following 2 things:
|
||||
*
|
||||
* 1. Data.
|
||||
* 2. IRQ handler function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Type of the handler function for every user IRQ request.
|
||||
*/
|
||||
typedef void ( * UserIrqHandlerFunction_t )( uint32_t ulData );
|
||||
|
||||
/**
|
||||
* @brief Represents user IRQ requests sent to the interrupt queue.
|
||||
*/
|
||||
typedef struct UserIrqRequest
|
||||
{
|
||||
uint32_t ulData;
|
||||
UserIrqHandlerFunction_t xHandlerFunction;
|
||||
} UserIrqRequest_t;
|
||||
|
||||
/**
|
||||
* @brief Function that implements the interrupt handler task.
|
||||
*
|
||||
* A FreeRTOS queue, known as interrupt queue, which holds UserIrqRequest_t items,
|
||||
* is passed as the parameter to this task. The interrupt handler task reads the
|
||||
* user IRQ requests from the interrupt queue and invokes the corresponding
|
||||
* handlers.
|
||||
*/
|
||||
void vInterruptHandlerTask( void * pvParams );
|
||||
|
||||
#endif /* INTERRUPT_HANDLER_H_ */
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* BSP includes. */
|
||||
#include "board.h"
|
||||
|
||||
/* Demo interface include. */
|
||||
#include "led_demo.h"
|
||||
|
||||
/**
|
||||
* Represents which LEDs are on or off. pdTRUE is on.
|
||||
*/
|
||||
typedef struct LedState
|
||||
{
|
||||
BaseType_t xRed;
|
||||
BaseType_t xGreen;
|
||||
BaseType_t xBlue;
|
||||
} LedState_t;
|
||||
|
||||
/* The following needs to be placed in the shared memory as it is accessed in
|
||||
* the button pressed IRQ handler which is unprivileged. */
|
||||
static LedState_t xLedState __attribute__( ( section( "user_irq_shared_memory" ) ) );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Turn on RGB Led according to the xLedState.
|
||||
*/
|
||||
static void prvTurnOnRgbLed( void );
|
||||
|
||||
/**
|
||||
* @brief Turn off RGB Led.
|
||||
*/
|
||||
static void prvTurnOffRgbLed( void );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTurnOnRgbLed( void )
|
||||
{
|
||||
/* Setting the GPIO pin activates the color in RGB LED. */
|
||||
if( xLedState.xRed == pdTRUE )
|
||||
{
|
||||
GPIO_PortClear( GPIO, BOARD_LED_RED_GPIO_PORT, 1u << BOARD_LED_RED_GPIO_PIN );
|
||||
}
|
||||
if( xLedState.xGreen == pdTRUE )
|
||||
{
|
||||
GPIO_PortClear( GPIO, BOARD_LED_GREEN_GPIO_PORT, 1u << BOARD_LED_GREEN_GPIO_PIN );
|
||||
}
|
||||
if( xLedState.xBlue == pdTRUE )
|
||||
{
|
||||
GPIO_PortClear( GPIO, BOARD_LED_BLUE_GPIO_PORT, 1u << BOARD_LED_BLUE_GPIO_PIN );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTurnOffRgbLed( void )
|
||||
{
|
||||
/* Setting the pins high turns off the LED. */
|
||||
GPIO_PortSet( GPIO, BOARD_LED_RED_GPIO_PORT, 1u << BOARD_LED_RED_GPIO_PIN );
|
||||
GPIO_PortSet( GPIO, BOARD_LED_GREEN_GPIO_PORT, 1u << BOARD_LED_GREEN_GPIO_PIN );
|
||||
GPIO_PortSet( GPIO, BOARD_LED_BLUE_GPIO_PORT, 1u << BOARD_LED_BLUE_GPIO_PIN );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vLedDemoTask( void * pvParams )
|
||||
{
|
||||
/* Set the initial LED state. */
|
||||
xLedState.xRed = pdTRUE;
|
||||
xLedState.xGreen = pdTRUE;
|
||||
xLedState.xBlue = pdFALSE;
|
||||
|
||||
/* Silence compiler warnings about unused variables. */
|
||||
( void ) pvParams;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
prvTurnOnRgbLed();
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
|
||||
prvTurnOffRgbLed();
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vButtonPressedIRQHandler( uint32_t ulData )
|
||||
{
|
||||
BaseType_t xPreviousRed;
|
||||
|
||||
/* Data is not used. */
|
||||
( void ) ulData;
|
||||
|
||||
/* Shift to the next color. */
|
||||
xPreviousRed = xLedState.xRed;
|
||||
xLedState.xRed = xLedState.xGreen;
|
||||
xLedState.xGreen = xLedState.xBlue;
|
||||
xLedState.xBlue = xPreviousRed;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef LED_DEMO_H_
|
||||
#define LED_DEMO_H_
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief The function that implements the LED demo task.
|
||||
*
|
||||
* It periodically toggles the on board RGB led. The color of the LED changes
|
||||
* whenever the user presses the USER button on the NXP LPC55S69-EVK board.
|
||||
*/
|
||||
void vLedDemoTask( void * pvParams );
|
||||
|
||||
/**
|
||||
* @brief Handler for the button pressed IRQ.
|
||||
*
|
||||
* It changes the color of the LED.
|
||||
*
|
||||
* @param [in] ulData Not used.
|
||||
*/
|
||||
void vButtonPressedIRQHandler( uint32_t ulData );
|
||||
|
||||
#endif /* LED_DEMO_H_ */
|
||||
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/*
|
||||
* This demo demonstrates the best practice of deferring majority of the
|
||||
* interrupt processing work from IRQ handlers to an unprivileged task. IRQ
|
||||
* handlers execute in privileged mode and therefore, have access to all the
|
||||
* memories. Keeping the IRQ handlers small and deferring most of the work to
|
||||
* unprivileged task provides better security.
|
||||
*
|
||||
* This demo creates a queue, known as interrupt queue. IRQ handlers post
|
||||
* requests to this queue which are later served by an unprivileged interrupt
|
||||
* handler task.
|
||||
*
|
||||
* +-------------------------+
|
||||
* +--------->+ Interrupt Queue +------------+
|
||||
* | +-------------------------+ |
|
||||
* | | Fetch and Serve
|
||||
* Post | |
|
||||
* | v
|
||||
* | +------+--------+
|
||||
* +------+--------+ | |
|
||||
* | IRQ Handler | | |
|
||||
* | (Privileged) | | Interrupt |
|
||||
* +---------------+ | Handler |
|
||||
* | Task |
|
||||
* | (Unprivileged)|
|
||||
* | |
|
||||
* | |
|
||||
* +---------------+
|
||||
*
|
||||
* This demo show-cases the following 2 demos:
|
||||
* 1. LED Demo - The LED demo creates a task which periodically toggles the on
|
||||
* board RGB LED. Whenever user presses the USER button, the
|
||||
* user button pressed IRQ handler changes the color of the LED.
|
||||
* The user button pressed IRQ handler posts a request to the
|
||||
* interrupt queue and task of changing the LED color is deferred
|
||||
* to the unprivileged handler.
|
||||
* 2. UART Demo - The UART demo creates a task which prints a command menu on
|
||||
* the serial console and then waits for the user input. Whenever
|
||||
* user enters any input on the serial console to run a command,
|
||||
* the UART received IRQ handler handles it and prints the
|
||||
* appropriate response on the serial console. The UART received
|
||||
* IRQ handler posts a request to the interrupt queue and task of
|
||||
* handling the command and providing the response is deferred
|
||||
* to the unprivileged handler.
|
||||
*/
|
||||
|
||||
/* FreeRTOS kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* BSP includes. */
|
||||
#include "board.h"
|
||||
#include "clock_config.h"
|
||||
#include "fsl_debug_console.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_inputmux.h"
|
||||
#include "fsl_power.h"
|
||||
#include "fsl_pint.h"
|
||||
#include "fsl_usart.h"
|
||||
#include "pin_mux.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "led_demo.h"
|
||||
#include "uart_demo.h"
|
||||
#include "interrupt_handler_task.h"
|
||||
|
||||
/**
|
||||
* @brief Length of the interrupt queue.
|
||||
*/
|
||||
#define USER_IRQ_QUEUE_LEN 8
|
||||
#define USER_IRQ_QUEUE_BUF_SIZE ( sizeof( UserIrqRequest_t ) * USER_IRQ_QUEUE_LEN )
|
||||
|
||||
/**
|
||||
* @brief UART_MEM_START to (UART_MEM_START + UART_MEM_LEN) cover the range
|
||||
* used by USART_WriteBlocking().
|
||||
*/
|
||||
#define UART_MEM_START ( USART0 )
|
||||
#define UART_MEM_LEN ( 3648 )
|
||||
|
||||
/**
|
||||
* @brief GPIO_MEM_START to (GPIO_MEM_START + GPIO_MEM_LEN) covers the range
|
||||
* used for setting and clearing GPIO pins.
|
||||
*/
|
||||
#define GPIO_MEM_START ( 0x4008E200u )
|
||||
#define GPIO_MEM_LEN ( 256 )
|
||||
|
||||
/**
|
||||
* @brief Handle and storage for the interrupt queue shared between IRQ handlers
|
||||
* and the interrupt handler task.
|
||||
*/
|
||||
static QueueHandle_t xUserIrqQueueHandle;
|
||||
static StaticQueue_t xStaticQueue;
|
||||
static uint8_t ucQueueBuffer[ USER_IRQ_QUEUE_BUF_SIZE ];
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Initialize hardware.
|
||||
*/
|
||||
static void prvInitializeHardware( void );
|
||||
|
||||
/**
|
||||
* @brief Initialize user button pressed interrupt.
|
||||
*/
|
||||
static void prvInitializeUserButtonInterrupt( void );
|
||||
|
||||
/**
|
||||
* @brief Initialize UART received interrupt.
|
||||
*/
|
||||
static void prvInitializeUartReceivedInterrupt( void );
|
||||
|
||||
/**
|
||||
* @brief Handler for pin interrupt when USER button is pressed.
|
||||
*
|
||||
* The handler enqueues a user IRQ request for the IRQ to be further processed
|
||||
* in the unprivileged interrupt handler.
|
||||
*/
|
||||
static void userButtonPressedHandler( pint_pin_int_t xInterruptType, uint32_t ulMatchStatus );
|
||||
|
||||
/**
|
||||
* @brief Handler for UART interrupt when UART data is received.
|
||||
*
|
||||
* The handler enqueues a user IRQ request for the IRQ to be further processed
|
||||
* in the unprivileged interrupt handler.
|
||||
*/
|
||||
void FLEXCOMM0_IRQHandler( void );
|
||||
|
||||
/**
|
||||
* @brief Create the demo tasks.
|
||||
*/
|
||||
static void prvCreateDemoTasks( void );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitializeHardware( void )
|
||||
{
|
||||
/* Set BOD VBAT level to 1.65V. */
|
||||
POWER_SetBodVbatLevel( kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false );
|
||||
|
||||
/* Attach main clock divide to FLEXCOMM0 (debug console). */
|
||||
CLOCK_AttachClk( BOARD_DEBUG_UART_CLK_ATTACH );
|
||||
|
||||
/* Board initialization. */
|
||||
BOARD_InitBootPins();
|
||||
BOARD_InitBootClocks();
|
||||
BOARD_InitDebugConsole();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitializeUserButtonInterrupt( void )
|
||||
{
|
||||
/* Connect trigger sources to PINT. */
|
||||
INPUTMUX_Init( INPUTMUX );
|
||||
INPUTMUX_AttachSignal( INPUTMUX, kPINT_PinInt0, kINPUTMUX_GpioPort1Pin9ToPintsel );
|
||||
|
||||
/* Turnoff clock to inputmux to save power. Clock is only needed to make changes. */
|
||||
INPUTMUX_Deinit( INPUTMUX );
|
||||
|
||||
/* Initialize PINT. */
|
||||
PINT_Init( PINT );
|
||||
|
||||
/* Setup Pin Interrupt 0 for rising edge. */
|
||||
PINT_PinInterruptConfig( PINT, kPINT_PinInt0, kPINT_PinIntEnableRiseEdge, userButtonPressedHandler );
|
||||
|
||||
/* Enable callback for PINT0 by Index. */
|
||||
PINT_EnableCallbackByIndex( PINT, kPINT_PinInt0 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitializeUartReceivedInterrupt( void )
|
||||
{
|
||||
usart_config_t config;
|
||||
USART_GetDefaultConfig( &( config ) );
|
||||
config.enableTx = true;
|
||||
config.enableRx = true;
|
||||
USART_Init( USART0, &( config ), CLOCK_GetFlexCommClkFreq( 0U ) );
|
||||
|
||||
/* Enable RX interrupt. */
|
||||
USART_EnableInterrupts( USART0, kUSART_RxLevelInterruptEnable | kUSART_RxErrorInterruptEnable );
|
||||
EnableIRQ( FLEXCOMM0_IRQn );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void userButtonPressedHandler( pint_pin_int_t xInterruptType, uint32_t ulMatchStatus )
|
||||
{
|
||||
UserIrqRequest_t xIrqRequest;
|
||||
|
||||
/* Silence warnings about unused variables. */
|
||||
( void ) xInterruptType;
|
||||
( void ) ulMatchStatus;
|
||||
|
||||
/* Enqueue a request to user IRQ queue to be processed in the unprivileged
|
||||
* interrupt handler. */
|
||||
xIrqRequest.xHandlerFunction = vButtonPressedIRQHandler;
|
||||
xIrqRequest.ulData = 0; /* Not used. */
|
||||
xQueueSendFromISR( xUserIrqQueueHandle, &( xIrqRequest ), NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Override weak definition of FLEXCOMM0_IRQHandler */
|
||||
void FLEXCOMM0_IRQHandler(void)
|
||||
{
|
||||
UserIrqRequest_t xIrqRequest;
|
||||
|
||||
/* If new data arrived. */
|
||||
if( ( kUSART_RxFifoNotEmptyFlag | kUSART_RxError ) & USART_GetStatusFlags( USART0 ) )
|
||||
{
|
||||
/* Enqueue a request to user IRQ queue to be processed in the unprivileged
|
||||
* interrupt handler. */
|
||||
xIrqRequest.xHandlerFunction = vUartDataReceivedIRQHandler;
|
||||
xIrqRequest.ulData = ( uint32_t ) USART_ReadByte( USART0 );
|
||||
xQueueSendFromISR( xUserIrqQueueHandle, &( xIrqRequest ), NULL );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCreateDemoTasks( void )
|
||||
{
|
||||
static StackType_t xInterruptHandlerTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
static StackType_t xLedDemoTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
static StackType_t xUartDemoTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
|
||||
extern TaskHandle_t xUartDemoTaskHandle;
|
||||
extern uint32_t __user_irq_shared_memory_start__[];
|
||||
extern uint32_t __user_irq_shared_memory_end__[];
|
||||
uint32_t ulSharedMemoryLength = ( uint32_t )__user_irq_shared_memory_end__ - ( uint32_t )__user_irq_shared_memory_start__ + 1;
|
||||
|
||||
/* The interrupt handler task needs access to UART memory region too as we
|
||||
* write the response to UART from the interrupt handler in the UART demo. */
|
||||
TaskParameters_t xInterruptHandlerTaskParameters =
|
||||
{
|
||||
.pvTaskCode = vInterruptHandlerTask,
|
||||
.pcName = "InterruptHandlerTask",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = xUserIrqQueueHandle,
|
||||
.uxPriority = configMAX_PRIORITIES - 1, /* Run the interrupt handler task at the highest priority. */
|
||||
.puxStackBuffer = xInterruptHandlerTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ __user_irq_shared_memory_start__, ulSharedMemoryLength, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ ( void * ) UART_MEM_START, UART_MEM_LEN, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
TaskParameters_t xLedDemoTaskParameters =
|
||||
{
|
||||
.pvTaskCode = vLedDemoTask,
|
||||
.pcName = "LedDemoTask",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xLedDemoTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ __user_irq_shared_memory_start__, ulSharedMemoryLength, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ ( void * ) GPIO_MEM_START, GPIO_MEM_LEN, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
TaskParameters_t xUartDemoTaskParameters =
|
||||
{
|
||||
.pvTaskCode = vUartDemoTask,
|
||||
.pcName = "UartDemoTask",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xUartDemoTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ __user_irq_shared_memory_start__, ulSharedMemoryLength, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ ( void * ) UART_MEM_START, UART_MEM_LEN, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
|
||||
xTaskCreateRestricted( &( xInterruptHandlerTaskParameters ), NULL );
|
||||
xTaskCreateRestricted( &( xLedDemoTaskParameters ), NULL );
|
||||
xTaskCreateRestricted( &( xUartDemoTaskParameters ), &( xUartDemoTaskHandle ) );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Entry point.
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
/* Initialize board hardware. */
|
||||
prvInitializeHardware();
|
||||
|
||||
/* Create the interrupt queue for deferring work from ISRs to the
|
||||
* unprivileged interrupt handler task. */
|
||||
xUserIrqQueueHandle = xQueueCreateStatic( USER_IRQ_QUEUE_LEN,
|
||||
sizeof( UserIrqRequest_t ),
|
||||
ucQueueBuffer,
|
||||
&( xStaticQueue ) );
|
||||
|
||||
prvCreateDemoTasks();
|
||||
prvInitializeUserButtonInterrupt();
|
||||
prvInitializeUartReceivedInterrupt();
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Should never reach here. */
|
||||
for( ; ; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Stack overflow hook. */
|
||||
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
|
||||
{
|
||||
/* Force an assert. */
|
||||
configASSERT( pcTaskName == 0 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
|
||||
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that
|
||||
* is used by the Idle task. */
|
||||
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
|
||||
StackType_t ** ppxIdleTaskStackBuffer,
|
||||
uint32_t * pulIdleTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Idle task are declared inside this
|
||||
* function then they must be declared static - otherwise they will be
|
||||
* allocated on the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle
|
||||
* task's state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
* Note that, as the array is necessarily of type StackType_t,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
* application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
* to provide the memory that is used by the Timer service task. */
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
StackType_t ** ppxTimerTaskStackBuffer,
|
||||
uint32_t * pulTimerTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Timer task are declared inside this
|
||||
* function then they must be declared static - otherwise they will be
|
||||
* allocated on the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) );
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||
* task's state will be stored. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Timer task's stack. */
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||
* Note that, as the array is necessarily of type StackType_t,
|
||||
* configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "fsl_usart.h"
|
||||
|
||||
/* Demo interface include. */
|
||||
#include "uart_demo.h"
|
||||
|
||||
/**
|
||||
* @brief The command menu presented to the user.
|
||||
*/
|
||||
#define UART_COMMAND_MENU "\r\nChoose one of the following:\r\n" \
|
||||
"1. Get current tick count.\r\n" \
|
||||
"2. Get number of tasks.\r\n"
|
||||
#define UART_COMMAND_MENU_LEN ( sizeof( UART_COMMAND_MENU ) - 1 )
|
||||
|
||||
/**
|
||||
* @brief Prompt for the user input.
|
||||
*/
|
||||
#define UART_PROMPT_STR "> "
|
||||
#define UART_PROMPT_STR_LEN ( sizeof( UART_PROMPT_STR ) - 1 )
|
||||
|
||||
/**
|
||||
* @brief Valid commands entered by the user.
|
||||
*/
|
||||
#define GET_TICK_COUNT_COMMAND 49 /* ASCII code for char '1'. */
|
||||
#define GET_NUM_TASKS_COMMAND 50 /* ASCII code for char '2'. */
|
||||
|
||||
/**
|
||||
* @brief Length of the buffer used for the response.
|
||||
*/
|
||||
#define UART_RESPONSE_BUF_LEN ( 32 )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The following needs to be placed in the shared memory as it is accessed in
|
||||
* the UART received IRQ handler which is unprivileged. */
|
||||
TaskHandle_t xUartDemoTaskHandle __attribute__( ( section( "user_irq_shared_memory" ) ) );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vUartDemoTask( void * pvParams )
|
||||
{
|
||||
/* Silence compiler warnings about unused variables. */
|
||||
( void ) pvParams;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
USART_WriteBlocking( USART0, UART_COMMAND_MENU, UART_COMMAND_MENU_LEN );
|
||||
USART_WriteBlocking( USART0, UART_PROMPT_STR, UART_PROMPT_STR_LEN );
|
||||
|
||||
ulTaskNotifyTake( pdFALSE, portMAX_DELAY );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vUartDataReceivedIRQHandler( uint32_t ulData )
|
||||
{
|
||||
char response[ UART_RESPONSE_BUF_LEN ];
|
||||
|
||||
if( ulData == GET_TICK_COUNT_COMMAND )
|
||||
{
|
||||
TickType_t xTickCount = xTaskGetTickCount();
|
||||
snprintf( response, sizeof( response ), "%c\r\nTick Count: %u\r\n", ( char ) ulData, xTickCount );
|
||||
}
|
||||
else if( ulData == GET_NUM_TASKS_COMMAND )
|
||||
{
|
||||
UBaseType_t xTaskCount = uxTaskGetNumberOfTasks();
|
||||
snprintf( response, sizeof( response ), "%c\r\nTask Count: %u\r\n", ( char ) ulData, xTaskCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( response, sizeof( response ), "\r\nInvalid command: %c.\r\n", ( char ) ulData );
|
||||
}
|
||||
|
||||
/* Print the response and unblock the UART demo task. */
|
||||
USART_WriteBlocking( USART0, response, strlen( response ) );
|
||||
xTaskNotifyGive( xUartDemoTaskHandle );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef UART_DEMO_H_
|
||||
#define UART_DEMO_H_
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief The function that implements the UART demo.
|
||||
*
|
||||
* It prints a command menu on the serial console and then waits for a task
|
||||
* notification. Whenever user enters any input on the serial console to run a
|
||||
* command, the UART received IRQ handler handles it and prints the appropriate
|
||||
* response on the serial console. The IRQ handler then unblocks the UART task
|
||||
* using task notification.
|
||||
*/
|
||||
void vUartDemoTask( void * pvParams );
|
||||
|
||||
/**
|
||||
* @brief Handler for the UART received IRQ.
|
||||
*
|
||||
* @param [in] ulData Data entered by the user.
|
||||
*/
|
||||
void vUartDataReceivedIRQHandler( uint32_t ulData );
|
||||
|
||||
#endif /* UART_DEMO_H_ */
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* FreeRTOS V202107.00
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_TICKLESS_IDLE 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 200 )
|
||||
#define configMAX_PRIORITIES 5
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 )
|
||||
#define configMAX_TASK_NAME_LEN 20
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */
|
||||
#define configQUEUE_REGISTRY_SIZE 8
|
||||
#define configUSE_QUEUE_SETS 0
|
||||
#define configUSE_TIME_SLICING 0
|
||||
#define configUSE_NEWLIB_REENTRANT 0
|
||||
#define configENABLE_BACKWARD_COMPATIBILITY 0
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||
|
||||
/* Used memory allocation (heap_x.c). */
|
||||
#define configFRTOS_MEMORY_SCHEME 4
|
||||
/* Tasks.c additions (e.g. Thread Aware Debug capability) */
|
||||
#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1
|
||||
|
||||
/* Memory allocation related definitions. */
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t )( 10 * 1024 ) )
|
||||
#define configAPPLICATION_ALLOCATED_HEAP 0
|
||||
|
||||
/* Hook function related definitions. */
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
|
||||
|
||||
/* Run time and task stats gathering related definitions. */
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
|
||||
|
||||
/* Task aware debugging. */
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
|
||||
/* Co-routine related definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES 2
|
||||
|
||||
/* Software timer related definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 10
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
/* Define to trap errors during development. */
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for (;;); }
|
||||
|
||||
/* Optional functions - most linkers will remove unused functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 0
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 0
|
||||
#define INCLUDE_eTaskGetState 0
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 0
|
||||
#define INCLUDE_xTaskGetHandle 0
|
||||
#define INCLUDE_xTaskResumeFromISR 1
|
||||
|
||||
|
||||
|
||||
#if defined(__ICCARM__)||defined(__CC_ARM)||defined(__GNUC__)
|
||||
/* Clock manager provides in this variable system core clock frequency */
|
||||
#include <stdint.h>
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef configENABLE_FPU
|
||||
#define configENABLE_FPU 1
|
||||
#endif
|
||||
#ifndef configENABLE_MPU
|
||||
#define configENABLE_MPU 1
|
||||
#endif
|
||||
#ifndef configENABLE_TRUSTZONE
|
||||
#define configENABLE_TRUSTZONE 0
|
||||
#endif
|
||||
#ifndef configRUN_FREERTOS_SECURE_ONLY
|
||||
#define configRUN_FREERTOS_SECURE_ONLY 1
|
||||
#endif
|
||||
|
||||
/* Interrupt nesting behaviour configuration. Cortex-M specific. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
#else
|
||||
#define configPRIO_BITS 3 /* 8 priority levels */
|
||||
#endif
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ( ( 1U << ( configPRIO_BITS ) ) - 1 )
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) )
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) )
|
||||
|
||||
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||
standard names. */
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
#define vPortPendSVHandler PendSV_Handler
|
||||
#define vPortSysTickHandler SysTick_Handler
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
+894
File diff suppressed because it is too large
Load Diff
+1444
File diff suppressed because it is too large
Load Diff
+1891
File diff suppressed because it is too large
Load Diff
+283
@@ -0,0 +1,283 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_compiler.h
|
||||
* @brief CMSIS compiler generic header file
|
||||
* @version V5.1.0
|
||||
* @date 09. October 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_COMPILER_H
|
||||
#define __CMSIS_COMPILER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Arm Compiler 4/5
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#include "cmsis_armcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Arm Compiler 6.6 LTM (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
|
||||
#include "cmsis_armclang_ltm.h"
|
||||
|
||||
/*
|
||||
* Arm Compiler above 6.10.1 (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
|
||||
#include "cmsis_armclang.h"
|
||||
|
||||
|
||||
/*
|
||||
* GNU Compiler
|
||||
*/
|
||||
#elif defined ( __GNUC__ )
|
||||
#include "cmsis_gcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* IAR Compiler
|
||||
*/
|
||||
#elif defined ( __ICCARM__ )
|
||||
#include <cmsis_iccarm.h>
|
||||
|
||||
|
||||
/*
|
||||
* TI Arm Compiler
|
||||
*/
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* TASKING Compiler
|
||||
*/
|
||||
#elif defined ( __TASKING__ )
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __packed__
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __packed__ T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __align(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* COSMIC Compiler
|
||||
*/
|
||||
#elif defined ( __CSMC__ )
|
||||
#include <cmsis_csm.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM _asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
// NO RETURN is automatically detected hence no warning here
|
||||
#define __NO_RETURN
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||
#define __USED
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED @packed
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT @packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION @packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
@packed struct T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
#ifndef __COMPILER_BARRIER
|
||||
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
|
||||
#define __COMPILER_BARRIER() (void)0
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#error Unknown compiler.
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CMSIS_COMPILER_H */
|
||||
|
||||
+2168
File diff suppressed because it is too large
Load Diff
+964
File diff suppressed because it is too large
Load Diff
+39
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.3
|
||||
* @date 24. June 2019
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2019 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
+2910
File diff suppressed because it is too large
Load Diff
+346
@@ -0,0 +1,346 @@
|
||||
/******************************************************************************
|
||||
* @file mpu_armv8.h
|
||||
* @brief CMSIS MPU API for Armv8-M and Armv8.1-M MPU
|
||||
* @version V5.1.0
|
||||
* @date 08. March 2019
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2019 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MPU_ARMV8_H
|
||||
#define ARM_MPU_ARMV8_H
|
||||
|
||||
/** \brief Attribute for device memory (outer only) */
|
||||
#define ARM_MPU_ATTR_DEVICE ( 0U )
|
||||
|
||||
/** \brief Attribute for non-cacheable, normal memory */
|
||||
#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U )
|
||||
|
||||
/** \brief Attribute for normal memory (outer and inner)
|
||||
* \param NT Non-Transient: Set to 1 for non-transient data.
|
||||
* \param WB Write-Back: Set to 1 to use write-back update policy.
|
||||
* \param RA Read Allocation: Set to 1 to use cache allocation on read miss.
|
||||
* \param WA Write Allocation: Set to 1 to use cache allocation on write miss.
|
||||
*/
|
||||
#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \
|
||||
(((NT & 1U) << 3U) | ((WB & 1U) << 2U) | ((RA & 1U) << 1U) | (WA & 1U))
|
||||
|
||||
/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U)
|
||||
|
||||
/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGnRE (1U)
|
||||
|
||||
/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGRE (2U)
|
||||
|
||||
/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_GRE (3U)
|
||||
|
||||
/** \brief Memory Attribute
|
||||
* \param O Outer memory attributes
|
||||
* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes
|
||||
*/
|
||||
#define ARM_MPU_ATTR(O, I) (((O & 0xFU) << 4U) | (((O & 0xFU) != 0U) ? (I & 0xFU) : ((I & 0x3U) << 2U)))
|
||||
|
||||
/** \brief Normal memory non-shareable */
|
||||
#define ARM_MPU_SH_NON (0U)
|
||||
|
||||
/** \brief Normal memory outer shareable */
|
||||
#define ARM_MPU_SH_OUTER (2U)
|
||||
|
||||
/** \brief Normal memory inner shareable */
|
||||
#define ARM_MPU_SH_INNER (3U)
|
||||
|
||||
/** \brief Memory access permissions
|
||||
* \param RO Read-Only: Set to 1 for read-only memory.
|
||||
* \param NP Non-Privileged: Set to 1 for non-privileged memory.
|
||||
*/
|
||||
#define ARM_MPU_AP_(RO, NP) (((RO & 1U) << 1U) | (NP & 1U))
|
||||
|
||||
/** \brief Region Base Address Register value
|
||||
* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned.
|
||||
* \param SH Defines the Shareability domain for this memory region.
|
||||
* \param RO Read-Only: Set to 1 for a read-only memory region.
|
||||
* \param NP Non-Privileged: Set to 1 for a non-privileged memory region.
|
||||
* \oaram XN eXecute Never: Set to 1 for a non-executable memory region.
|
||||
*/
|
||||
#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \
|
||||
((BASE & MPU_RBAR_BASE_Msk) | \
|
||||
((SH << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \
|
||||
((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \
|
||||
((XN << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk))
|
||||
|
||||
/** \brief Region Limit Address Register value
|
||||
* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended.
|
||||
* \param IDX The attribute index to be associated with this memory region.
|
||||
*/
|
||||
#define ARM_MPU_RLAR(LIMIT, IDX) \
|
||||
((LIMIT & MPU_RLAR_LIMIT_Msk) | \
|
||||
((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
|
||||
(MPU_RLAR_EN_Msk))
|
||||
|
||||
#if defined(MPU_RLAR_PXN_Pos)
|
||||
|
||||
/** \brief Region Limit Address Register with PXN value
|
||||
* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended.
|
||||
* \param PXN Privileged execute never. Defines whether code can be executed from this privileged region.
|
||||
* \param IDX The attribute index to be associated with this memory region.
|
||||
*/
|
||||
#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \
|
||||
((LIMIT & MPU_RLAR_LIMIT_Msk) | \
|
||||
((PXN << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \
|
||||
((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
|
||||
(MPU_RLAR_EN_Msk))
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct for a single MPU Region
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t RBAR; /*!< Region Base Address Register value */
|
||||
uint32_t RLAR; /*!< Region Limit Address Register value */
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
|
||||
{
|
||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
/** Disable the MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable(void)
|
||||
{
|
||||
__DMB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Enable the Non-secure MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control)
|
||||
{
|
||||
MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
/** Disable the Non-secure MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable_NS(void)
|
||||
{
|
||||
__DMB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Set the memory attribute encoding to the given MPU.
|
||||
* \param mpu Pointer to the MPU to be configured.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr)
|
||||
{
|
||||
const uint8_t reg = idx / 4U;
|
||||
const uint32_t pos = ((idx % 4U) * 8U);
|
||||
const uint32_t mask = 0xFFU << pos;
|
||||
|
||||
if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) {
|
||||
return; // invalid index
|
||||
}
|
||||
|
||||
mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask));
|
||||
}
|
||||
|
||||
/** Set the memory attribute encoding.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr)
|
||||
{
|
||||
ARM_MPU_SetMemAttrEx(MPU, idx, attr);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Set the memory attribute encoding to the Non-secure MPU.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr)
|
||||
{
|
||||
ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Clear and disable the given MPU region of the given MPU.
|
||||
* \param mpu Pointer to MPU to be used.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr)
|
||||
{
|
||||
mpu->RNR = rnr;
|
||||
mpu->RLAR = 0U;
|
||||
}
|
||||
|
||||
/** Clear and disable the given MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
{
|
||||
ARM_MPU_ClrRegionEx(MPU, rnr);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Clear and disable the given Non-secure MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr)
|
||||
{
|
||||
ARM_MPU_ClrRegionEx(MPU_NS, rnr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Configure the given MPU region of the given MPU.
|
||||
* \param mpu Pointer to MPU to be used.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
mpu->RNR = rnr;
|
||||
mpu->RBAR = rbar;
|
||||
mpu->RLAR = rlar;
|
||||
}
|
||||
|
||||
/** Configure the given MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Configure the given Non-secure MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Memcopy with strictly ordered memory access, e.g. for register targets.
|
||||
* \param dst Destination data is copied to.
|
||||
* \param src Source data is copied from.
|
||||
* \param len Amount of data words to be copied.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table to the given MPU.
|
||||
* \param mpu Pointer to the MPU registers to be used.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
if (cnt == 1U) {
|
||||
mpu->RNR = rnr;
|
||||
ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize);
|
||||
} else {
|
||||
uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U);
|
||||
uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES;
|
||||
|
||||
mpu->RNR = rnrBase;
|
||||
while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) {
|
||||
uint32_t c = MPU_TYPE_RALIASES - rnrOffset;
|
||||
ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize);
|
||||
table += c;
|
||||
cnt -= c;
|
||||
rnrOffset = 0U;
|
||||
rnrBase += MPU_TYPE_RALIASES;
|
||||
mpu->RNR = rnrBase;
|
||||
}
|
||||
|
||||
ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize);
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
ARM_MPU_LoadEx(MPU, rnr, table, cnt);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Load the given number of MPU regions from a table to the Non-secure MPU.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/******************************************************************************
|
||||
* @file tz_context.h
|
||||
* @brief Context Management for Armv8-M TrustZone
|
||||
* @version V1.0.1
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef TZ_CONTEXT_H
|
||||
#define TZ_CONTEXT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef TZ_MODULEID_T
|
||||
#define TZ_MODULEID_T
|
||||
/// \details Data type that identifies secure software modules called by a process.
|
||||
typedef uint32_t TZ_ModuleId_t;
|
||||
#endif
|
||||
|
||||
/// \details TZ Memory ID identifies an allocated memory slot.
|
||||
typedef uint32_t TZ_MemoryId_t;
|
||||
|
||||
/// Initialize secure context memory system
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_InitContextSystem_S (void);
|
||||
|
||||
/// Allocate context memory for calling secure software modules in TrustZone
|
||||
/// \param[in] module identifies software modules called from non-secure mode
|
||||
/// \return value != 0 id TrustZone memory slot identifier
|
||||
/// \return value 0 no memory available or internal error
|
||||
TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
|
||||
|
||||
/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
|
||||
|
||||
/// Load secure context (called on RTOS thread context switch)
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
|
||||
|
||||
/// Store secure context (called on RTOS thread context switch)
|
||||
/// \param[in] id TrustZone memory slot identifier
|
||||
/// \return execution status (1: success, 0: error)
|
||||
uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
|
||||
|
||||
#endif // TZ_CONTEXT_H
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016, NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_power.h"
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.power"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
/* Empty file since implementation is in header file and power library */
|
||||
+626
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_debug_console.h"
|
||||
#include "board.h"
|
||||
#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
|
||||
#include "fsl_i2c.h"
|
||||
#endif /* SDK_I2C_BASED_COMPONENT_USED */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* Initialize debug console. */
|
||||
void BOARD_InitDebugConsole(void)
|
||||
{
|
||||
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
|
||||
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
|
||||
|
||||
RESET_ClearPeripheralReset(BOARD_DEBUG_UART_RST);
|
||||
|
||||
uint32_t uartClkSrcFreq = BOARD_DEBUG_UART_CLK_FREQ;
|
||||
|
||||
DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_DEBUG_UART_BAUDRATE, BOARD_DEBUG_UART_TYPE, uartClkSrcFreq);
|
||||
}
|
||||
|
||||
void BOARD_InitDebugConsole_Core1(void)
|
||||
{
|
||||
/* attach 12 MHz clock to FLEXCOMM1 (debug console) */
|
||||
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH_CORE1);
|
||||
|
||||
RESET_ClearPeripheralReset(BOARD_DEBUG_UART_RST_CORE1);
|
||||
|
||||
uint32_t uartClkSrcFreq = BOARD_DEBUG_UART_CLK_FREQ_CORE1;
|
||||
|
||||
DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE_CORE1, BOARD_DEBUG_UART_BAUDRATE_CORE1, BOARD_DEBUG_UART_TYPE_CORE1,
|
||||
uartClkSrcFreq);
|
||||
}
|
||||
|
||||
#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
|
||||
void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz)
|
||||
{
|
||||
i2c_master_config_t i2cConfig = {0};
|
||||
|
||||
I2C_MasterGetDefaultConfig(&i2cConfig);
|
||||
I2C_MasterInit(base, &i2cConfig, clkSrc_Hz);
|
||||
}
|
||||
|
||||
status_t BOARD_I2C_Send(I2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize)
|
||||
{
|
||||
i2c_master_transfer_t masterXfer;
|
||||
|
||||
/* Prepare transfer structure. */
|
||||
masterXfer.slaveAddress = deviceAddress;
|
||||
masterXfer.direction = kI2C_Write;
|
||||
masterXfer.subaddress = subAddress;
|
||||
masterXfer.subaddressSize = subaddressSize;
|
||||
masterXfer.data = txBuff;
|
||||
masterXfer.dataSize = txBuffSize;
|
||||
masterXfer.flags = kI2C_TransferDefaultFlag;
|
||||
|
||||
return I2C_MasterTransferBlocking(base, &masterXfer);
|
||||
}
|
||||
|
||||
status_t BOARD_I2C_Receive(I2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize)
|
||||
{
|
||||
i2c_master_transfer_t masterXfer;
|
||||
|
||||
/* Prepare transfer structure. */
|
||||
masterXfer.slaveAddress = deviceAddress;
|
||||
masterXfer.subaddress = subAddress;
|
||||
masterXfer.subaddressSize = subaddressSize;
|
||||
masterXfer.data = rxBuff;
|
||||
masterXfer.dataSize = rxBuffSize;
|
||||
masterXfer.direction = kI2C_Read;
|
||||
masterXfer.flags = kI2C_TransferDefaultFlag;
|
||||
|
||||
return I2C_MasterTransferBlocking(base, &masterXfer);
|
||||
}
|
||||
|
||||
void BOARD_Accel_I2C_Init(void)
|
||||
{
|
||||
BOARD_I2C_Init(BOARD_ACCEL_I2C_BASEADDR, BOARD_ACCEL_I2C_CLOCK_FREQ);
|
||||
}
|
||||
|
||||
status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff)
|
||||
{
|
||||
uint8_t data = (uint8_t)txBuff;
|
||||
|
||||
return BOARD_I2C_Send(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, &data, 1);
|
||||
}
|
||||
|
||||
status_t BOARD_Accel_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize)
|
||||
{
|
||||
return BOARD_I2C_Receive(BOARD_ACCEL_I2C_BASEADDR, deviceAddress, subAddress, subaddressSize, rxBuff, rxBuffSize);
|
||||
}
|
||||
|
||||
void BOARD_Codec_I2C_Init(void)
|
||||
{
|
||||
BOARD_I2C_Init(BOARD_CODEC_I2C_BASEADDR, BOARD_CODEC_I2C_CLOCK_FREQ);
|
||||
}
|
||||
|
||||
status_t BOARD_Codec_I2C_Send(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize)
|
||||
{
|
||||
return BOARD_I2C_Send(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff,
|
||||
txBuffSize);
|
||||
}
|
||||
|
||||
status_t BOARD_Codec_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize)
|
||||
{
|
||||
return BOARD_I2C_Receive(BOARD_CODEC_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, rxBuffSize);
|
||||
}
|
||||
#endif /* SDK_I2C_BASED_COMPONENT_USED */
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
#include "clock_config.h"
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_reset.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_iocon.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief The board name */
|
||||
#define BOARD_NAME "LPCXpresso55S69"
|
||||
|
||||
/*! @brief The UART to use for debug messages. */
|
||||
/* TODO: rename UART to USART */
|
||||
#define BOARD_DEBUG_UART_TYPE kSerialPort_Uart
|
||||
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) USART0
|
||||
#define BOARD_DEBUG_UART_INSTANCE 0U
|
||||
#define BOARD_DEBUG_UART_CLK_FREQ 12000000U
|
||||
#define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0
|
||||
#define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn
|
||||
#define BOARD_DEBUG_UART_CLKSRC kCLOCK_Flexcomm0
|
||||
#define BOARD_UART_IRQ_HANDLER FLEXCOMM0_IRQHandler
|
||||
#define BOARD_UART_IRQ FLEXCOMM0_IRQn
|
||||
|
||||
#define BOARD_ACCEL_I2C_BASEADDR I2C4
|
||||
#define BOARD_ACCEL_I2C_CLOCK_FREQ 12000000
|
||||
|
||||
#define BOARD_DEBUG_UART_TYPE_CORE1 kSerialPort_Uart
|
||||
#define BOARD_DEBUG_UART_BASEADDR_CORE1 (uint32_t) USART1
|
||||
#define BOARD_DEBUG_UART_INSTANCE_CORE1 1U
|
||||
#define BOARD_DEBUG_UART_CLK_FREQ_CORE1 12000000U
|
||||
#define BOARD_DEBUG_UART_CLK_ATTACH_CORE1 kFRO12M_to_FLEXCOMM1
|
||||
#define BOARD_DEBUG_UART_RST_CORE1 kFC1_RST_SHIFT_RSTn
|
||||
#define BOARD_DEBUG_UART_CLKSRC_CORE1 kCLOCK_Flexcomm1
|
||||
#define BOARD_UART_IRQ_HANDLER_CORE1 FLEXCOMM1_IRQHandler
|
||||
#define BOARD_UART_IRQ_CORE1 FLEXCOMM1_IRQn
|
||||
|
||||
#ifndef BOARD_DEBUG_UART_BAUDRATE
|
||||
#define BOARD_DEBUG_UART_BAUDRATE 115200U
|
||||
#endif /* BOARD_DEBUG_UART_BAUDRATE */
|
||||
|
||||
#ifndef BOARD_DEBUG_UART_BAUDRATE_CORE1
|
||||
#define BOARD_DEBUG_UART_BAUDRATE_CORE1 115200U
|
||||
#endif /* BOARD_DEBUG_UART_BAUDRATE_CORE1 */
|
||||
|
||||
#define BOARD_CODEC_I2C_BASEADDR I2C4
|
||||
#define BOARD_CODEC_I2C_CLOCK_FREQ 12000000
|
||||
#define BOARD_CODEC_I2C_INSTANCE 4
|
||||
#ifndef BOARD_LED_RED_GPIO
|
||||
#define BOARD_LED_RED_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_LED_RED_GPIO_PORT 1U
|
||||
#ifndef BOARD_LED_RED_GPIO_PIN
|
||||
#define BOARD_LED_RED_GPIO_PIN 6U
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_LED_BLUE_GPIO
|
||||
#define BOARD_LED_BLUE_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_LED_BLUE_GPIO_PORT 1U
|
||||
#ifndef BOARD_LED_BLUE_GPIO_PIN
|
||||
#define BOARD_LED_BLUE_GPIO_PIN 4U
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_LED_GREEN_GPIO
|
||||
#define BOARD_LED_GREEN_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_LED_GREEN_GPIO_PORT 1U
|
||||
#ifndef BOARD_LED_GREEN_GPIO_PIN
|
||||
#define BOARD_LED_GREEN_GPIO_PIN 7U
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_SW1_GPIO
|
||||
#define BOARD_SW1_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_SW1_GPIO_PORT 0U
|
||||
#ifndef BOARD_SW1_GPIO_PIN
|
||||
#define BOARD_SW1_GPIO_PIN 5U
|
||||
#endif
|
||||
#define BOARD_SW1_NAME "SW1"
|
||||
#define BOARD_SW1_IRQ PIN_INT0_IRQn
|
||||
#define BOARD_SW1_IRQ_HANDLER PIN_INT0_IRQHandler
|
||||
|
||||
#ifndef BOARD_SW2_GPIO
|
||||
#define BOARD_SW2_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_SW2_GPIO_PORT 1U
|
||||
#ifndef BOARD_SW2_GPIO_PIN
|
||||
#define BOARD_SW2_GPIO_PIN 18U
|
||||
#endif
|
||||
#define BOARD_SW2_NAME "SW2"
|
||||
#define BOARD_SW2_IRQ PIN_INT1_IRQn
|
||||
#define BOARD_SW2_IRQ_HANDLER PIN_INT1_IRQHandler
|
||||
#define BOARD_SW2_GPIO_PININT_INDEX 1
|
||||
|
||||
#ifndef BOARD_SW3_GPIO
|
||||
#define BOARD_SW3_GPIO GPIO
|
||||
#endif
|
||||
#define BOARD_SW3_GPIO_PORT 1U
|
||||
#ifndef BOARD_SW3_GPIO_PIN
|
||||
#define BOARD_SW3_GPIO_PIN 9U
|
||||
#endif
|
||||
#define BOARD_SW3_NAME "SW3"
|
||||
#define BOARD_SW3_IRQ PIN_INT1_IRQn
|
||||
#define BOARD_SW3_IRQ_HANDLER PIN_INT1_IRQHandler
|
||||
#define BOARD_SW3_GPIO_PININT_INDEX 1
|
||||
|
||||
/* Board led color mapping */
|
||||
#define LOGIC_LED_ON 0U
|
||||
#define LOGIC_LED_OFF 1U
|
||||
|
||||
#define LED_RED_INIT(output) \
|
||||
{ \
|
||||
IOCON_PinMuxSet(IOCON, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, IOCON_DIGITAL_EN); \
|
||||
GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \
|
||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \
|
||||
}
|
||||
#define LED_RED_ON() \
|
||||
GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
|
||||
1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED1 */
|
||||
#define LED_RED_OFF() \
|
||||
GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
|
||||
1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED1 \ \ \ \ \ \ \ \ \ \ \
|
||||
*/
|
||||
#define LED_RED_TOGGLE() \
|
||||
GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
|
||||
1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED1 */
|
||||
|
||||
#define LED_BLUE_INIT(output) \
|
||||
{ \
|
||||
IOCON_PinMuxSet(IOCON, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, IOCON_DIGITAL_EN); \
|
||||
GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \
|
||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \
|
||||
}
|
||||
#define LED_BLUE_ON() \
|
||||
GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
|
||||
1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED1 */
|
||||
#define LED_BLUE_OFF() \
|
||||
GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
|
||||
1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED1 */
|
||||
#define LED_BLUE_TOGGLE() \
|
||||
GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
|
||||
1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED1 */
|
||||
|
||||
#define LED_GREEN_INIT(output) \
|
||||
GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \
|
||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED1 */
|
||||
#define LED_GREEN_ON() \
|
||||
GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
|
||||
1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED1 */
|
||||
#define LED_GREEN_OFF() \
|
||||
GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
|
||||
1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED1 */
|
||||
#define LED_GREEN_TOGGLE() \
|
||||
GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
|
||||
1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED1 */
|
||||
|
||||
/* Display. */
|
||||
#define BOARD_LCD_DC_GPIO GPIO
|
||||
#define BOARD_LCD_DC_GPIO_PORT 1U
|
||||
#define BOARD_LCD_DC_GPIO_PIN 5U
|
||||
|
||||
/* Serial MWM WIFI */
|
||||
#define BOARD_SERIAL_MWM_PORT_CLK_FREQ CLOCK_GetFlexCommClkFreq(2)
|
||||
#define BOARD_SERIAL_MWM_PORT USART2
|
||||
#define BOARD_SERIAL_MWM_PORT_IRQn FLEXCOMM2_IRQn
|
||||
#define BOARD_SERIAL_MWM_RST_WRITE(output)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
void BOARD_InitDebugConsole(void);
|
||||
void BOARD_InitDebugConsole_Core1(void);
|
||||
#if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED
|
||||
void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz);
|
||||
status_t BOARD_I2C_Send(I2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize);
|
||||
status_t BOARD_I2C_Receive(I2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize);
|
||||
void BOARD_Accel_I2C_Init(void);
|
||||
status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff);
|
||||
status_t BOARD_Accel_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
|
||||
void BOARD_Codec_I2C_Init(void);
|
||||
status_t BOARD_Codec_I2C_Send(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
|
||||
status_t BOARD_Codec_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
|
||||
#endif /* SDK_I2C_BASED_COMPONENT_USED */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _BOARD_H_ */
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
/***********************************************************************************************************************
|
||||
* This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
|
||||
* will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
|
||||
**********************************************************************************************************************/
|
||||
/*
|
||||
* How to set up clock using clock driver functions:
|
||||
*
|
||||
* 1. Setup clock sources.
|
||||
*
|
||||
* 2. Set up wait states of the flash.
|
||||
*
|
||||
* 3. Set up all dividers.
|
||||
*
|
||||
* 4. Set up all selectors to provide selected clocks.
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Clocks v8.0
|
||||
processor: LPC55S69
|
||||
package_id: LPC55S69JBD100
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 10.0.0
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
#include "fsl_power.h"
|
||||
#include "fsl_clock.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/* System clock frequency. */
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/*******************************************************************************
|
||||
************************ BOARD_InitBootClocks function ************************
|
||||
******************************************************************************/
|
||||
void BOARD_InitBootClocks(void)
|
||||
{
|
||||
BOARD_BootClockPLL150M();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockFRO12M **********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockFRO12M
|
||||
outputs:
|
||||
- {id: System_clock.outFreq, value: 12 MHz}
|
||||
settings:
|
||||
- {id: ANALOG_CONTROL_FRO192M_CTRL_ENDI_FRO_96M_CFG, value: Enable}
|
||||
sources:
|
||||
- {id: ANACTRL.fro_hf.outFreq, value: 96 MHz}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockFRO12M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockFRO12M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockFRO12M(void)
|
||||
{
|
||||
#ifndef SDK_SECONDARY_CORE
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Configure FRO192M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
|
||||
CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change the clock setting */
|
||||
|
||||
CLOCK_SetupFROClocking(96000000U); /* Enable FRO HF(96MHz) output */
|
||||
|
||||
POWER_SetVoltageForFreq(12000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(12000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO12M */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKFRO12M_CORE_CLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************* Configuration BOARD_BootClockFROHF96M *********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockFROHF96M
|
||||
outputs:
|
||||
- {id: System_clock.outFreq, value: 96 MHz}
|
||||
settings:
|
||||
- {id: ANALOG_CONTROL_FRO192M_CTRL_ENDI_FRO_96M_CFG, value: Enable}
|
||||
- {id: SYSCON.MAINCLKSELA.sel, value: ANACTRL.fro_hf_clk}
|
||||
sources:
|
||||
- {id: ANACTRL.fro_hf.outFreq, value: 96 MHz}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockFROHF96M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockFROHF96M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockFROHF96M(void)
|
||||
{
|
||||
#ifndef SDK_SECONDARY_CORE
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Configure FRO192M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
|
||||
CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change the clock setting */
|
||||
|
||||
CLOCK_SetupFROClocking(96000000U); /* Enable FRO HF(96MHz) output */
|
||||
|
||||
POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL100M *********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockPLL100M
|
||||
outputs:
|
||||
- {id: System_clock.outFreq, value: 100 MHz}
|
||||
settings:
|
||||
- {id: PLL0_Mode, value: Normal}
|
||||
- {id: ANALOG_CONTROL_FRO192M_CTRL_ENDI_FRO_96M_CFG, value: Enable}
|
||||
- {id: ENABLE_CLKIN_ENA, value: Enabled}
|
||||
- {id: ENABLE_SYSTEM_CLK_OUT, value: Enabled}
|
||||
- {id: SYSCON.MAINCLKSELB.sel, value: SYSCON.PLL0_BYPASS}
|
||||
- {id: SYSCON.PLL0CLKSEL.sel, value: SYSCON.CLK_IN_EN}
|
||||
- {id: SYSCON.PLL0M_MULT.scale, value: '100', locked: true}
|
||||
- {id: SYSCON.PLL0N_DIV.scale, value: '4', locked: true}
|
||||
- {id: SYSCON.PLL0_PDEC.scale, value: '4', locked: true}
|
||||
sources:
|
||||
- {id: ANACTRL.fro_hf.outFreq, value: 96 MHz}
|
||||
- {id: SYSCON.XTAL32M.outFreq, value: 16 MHz, enabled: true}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockPLL100M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockPLL100M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockPLL100M(void)
|
||||
{
|
||||
#ifndef SDK_SECONDARY_CORE
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Configure FRO192M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
|
||||
CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change the clock setting */
|
||||
|
||||
CLOCK_SetupFROClocking(96000000U); /* Enable FRO HF(96MHz) output */
|
||||
|
||||
/*!< Configure XTAL32M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_XTAL32M); /* Ensure XTAL32M is powered */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_LDOXO32M); /* Ensure XTAL32M is powered */
|
||||
CLOCK_SetupExtClocking(16000000U); /* Enable clk_in clock */
|
||||
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; /* Enable clk_in from XTAL32M clock */
|
||||
ANACTRL->XO32M_CTRL |= ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK; /* Enable clk_in to system */
|
||||
|
||||
POWER_SetVoltageForFreq(100000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(100000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up PLL */
|
||||
CLOCK_AttachClk(kEXT_CLK_to_PLL0); /*!< Switch PLL0CLKSEL to EXT_CLK */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_PLL0); /* Ensure PLL is on */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
|
||||
const pll_setup_t pll0Setup = {
|
||||
.pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(53U) | SYSCON_PLL0CTRL_SELP(26U),
|
||||
.pllndec = SYSCON_PLL0NDEC_NDIV(4U),
|
||||
.pllpdec = SYSCON_PLL0PDEC_PDIV(2U),
|
||||
.pllsscg = {0x0U,(SYSCON_PLL0SSCG1_MDIV_EXT(100U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
|
||||
.pllRate = 100000000U,
|
||||
.flags = PLL_SETUPFLAG_WAITLOCK
|
||||
};
|
||||
CLOCK_SetPLL0Freq(&pll0Setup); /*!< Configure PLL0 to the desired values */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kPLL0_to_MAIN_CLK); /*!< Switch MAIN_CLK to PLL0 */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKPLL100M_CORE_CLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL150M *********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockPLL150M
|
||||
called_from_default_init: true
|
||||
outputs:
|
||||
- {id: System_clock.outFreq, value: 150 MHz}
|
||||
settings:
|
||||
- {id: PLL0_Mode, value: Normal}
|
||||
- {id: ENABLE_CLKIN_ENA, value: Enabled}
|
||||
- {id: ENABLE_SYSTEM_CLK_OUT, value: Enabled}
|
||||
- {id: SYSCON.MAINCLKSELB.sel, value: SYSCON.PLL0_BYPASS}
|
||||
- {id: SYSCON.PLL0CLKSEL.sel, value: SYSCON.CLK_IN_EN}
|
||||
- {id: SYSCON.PLL0M_MULT.scale, value: '150', locked: true}
|
||||
- {id: SYSCON.PLL0N_DIV.scale, value: '8', locked: true}
|
||||
- {id: SYSCON.PLL0_PDEC.scale, value: '2', locked: true}
|
||||
sources:
|
||||
- {id: SYSCON.XTAL32M.outFreq, value: 16 MHz, enabled: true}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockPLL150M(void)
|
||||
{
|
||||
#ifndef SDK_SECONDARY_CORE
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Configure FRO192M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
|
||||
CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change the clock setting */
|
||||
|
||||
/*!< Configure XTAL32M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_XTAL32M); /* Ensure XTAL32M is powered */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_LDOXO32M); /* Ensure XTAL32M is powered */
|
||||
CLOCK_SetupExtClocking(16000000U); /* Enable clk_in clock */
|
||||
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; /* Enable clk_in from XTAL32M clock */
|
||||
ANACTRL->XO32M_CTRL |= ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK; /* Enable clk_in to system */
|
||||
|
||||
POWER_SetVoltageForFreq(150000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(150000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up PLL */
|
||||
CLOCK_AttachClk(kEXT_CLK_to_PLL0); /*!< Switch PLL0CLKSEL to EXT_CLK */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_PLL0); /* Ensure PLL is on */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
|
||||
const pll_setup_t pll0Setup = {
|
||||
.pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(53U) | SYSCON_PLL0CTRL_SELP(31U),
|
||||
.pllndec = SYSCON_PLL0NDEC_NDIV(8U),
|
||||
.pllpdec = SYSCON_PLL0PDEC_PDIV(1U),
|
||||
.pllsscg = {0x0U,(SYSCON_PLL0SSCG1_MDIV_EXT(150U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
|
||||
.pllRate = 150000000U,
|
||||
.flags = PLL_SETUPFLAG_WAITLOCK
|
||||
};
|
||||
CLOCK_SetPLL0Freq(&pll0Setup); /*!< Configure PLL0 to the desired values */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kPLL0_to_MAIN_CLK); /*!< Switch MAIN_CLK to PLL0 */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKPLL150M_CORE_CLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
******************* Configuration BOARD_BootClockPLL1_150M ********************
|
||||
******************************************************************************/
|
||||
/* clang-format off */
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockPLL1_150M
|
||||
outputs:
|
||||
- {id: System_clock.outFreq, value: 150 MHz}
|
||||
settings:
|
||||
- {id: PLL1_Mode, value: Normal}
|
||||
- {id: ENABLE_CLKIN_ENA, value: Enabled}
|
||||
- {id: ENABLE_SYSTEM_CLK_OUT, value: Enabled}
|
||||
- {id: SYSCON.MAINCLKSELB.sel, value: SYSCON.PLL1_BYPASS}
|
||||
- {id: SYSCON.PLL1CLKSEL.sel, value: SYSCON.CLK_IN_EN}
|
||||
- {id: SYSCON.PLL1M_MULT.scale, value: '150', locked: true}
|
||||
- {id: SYSCON.PLL1N_DIV.scale, value: '8', locked: true}
|
||||
- {id: SYSCON.PLL1_PDEC.scale, value: '2', locked: true}
|
||||
sources:
|
||||
- {id: SYSCON.XTAL32M.outFreq, value: 16 MHz, enabled: true}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
/* clang-format on */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockPLL1_150M configuration
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockPLL1_150M configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockPLL1_150M(void)
|
||||
{
|
||||
#ifndef SDK_SECONDARY_CORE
|
||||
/*!< Set up the clock sources */
|
||||
/*!< Configure FRO192M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
|
||||
CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
|
||||
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change the clock setting */
|
||||
|
||||
/*!< Configure XTAL32M */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_XTAL32M); /* Ensure XTAL32M is powered */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_LDOXO32M); /* Ensure XTAL32M is powered */
|
||||
CLOCK_SetupExtClocking(16000000U); /* Enable clk_in clock */
|
||||
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; /* Enable clk_in from XTAL32M clock */
|
||||
ANACTRL->XO32M_CTRL |= ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK; /* Enable clk_in to system */
|
||||
|
||||
POWER_SetVoltageForFreq(150000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
|
||||
CLOCK_SetFLASHAccessCyclesForFreq(150000000U); /*!< Set FLASH wait states for core */
|
||||
|
||||
/*!< Set up PLL1 */
|
||||
CLOCK_AttachClk(kEXT_CLK_to_PLL1); /*!< Switch PLL1CLKSEL to EXT_CLK */
|
||||
POWER_DisablePD(kPDRUNCFG_PD_PLL1); /* Ensure PLL is on */
|
||||
const pll_setup_t pll1Setup = {
|
||||
.pllctrl = SYSCON_PLL1CTRL_CLKEN_MASK | SYSCON_PLL1CTRL_SELI(53U) | SYSCON_PLL1CTRL_SELP(31U),
|
||||
.pllndec = SYSCON_PLL1NDEC_NDIV(8U),
|
||||
.pllpdec = SYSCON_PLL1PDEC_PDIV(1U),
|
||||
.pllmdec = SYSCON_PLL1MDEC_MDIV(150U),
|
||||
.pllRate = 150000000U,
|
||||
.flags = PLL_SETUPFLAG_WAITLOCK
|
||||
};
|
||||
CLOCK_SetPLL1Freq(&pll1Setup); /*!< Configure PLL1 to the desired values */
|
||||
|
||||
/*!< Set up dividers */
|
||||
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
|
||||
|
||||
/*!< Set up clock selectors - Attach clocks to the peripheries */
|
||||
CLOCK_AttachClk(kPLL1_to_MAIN_CLK); /*!< Switch MAIN_CLK to PLL1 */
|
||||
|
||||
/*!< Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKPLL1_150M_CORE_CLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/***********************************************************************************************************************
|
||||
* This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
|
||||
* will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H_
|
||||
#define _CLOCK_CONFIG_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define BOARD_XTAL0_CLK_HZ 16000000U /*!< Board xtal frequency in Hz */
|
||||
#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32K frequency in Hz */
|
||||
|
||||
/*******************************************************************************
|
||||
************************ BOARD_InitBootClocks function ************************
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes default configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_InitBootClocks(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockFRO12M **********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockFRO12M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockFRO12M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockFRO12M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************* Configuration BOARD_BootClockFROHF96M *********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockFROHF96M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK 96000000U /*!< Core clock frequency: 96000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockFROHF96M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockFROHF96M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL100M *********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockPLL100M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKPLL100M_CORE_CLOCK 100000000U /*!< Core clock frequency: 100000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockPLL100M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockPLL100M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************** Configuration BOARD_BootClockPLL150M *********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKPLL150M_CORE_CLOCK 150000000U /*!< Core clock frequency: 150000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockPLL150M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockPLL150M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
******************* Configuration BOARD_BootClockPLL1_150M ********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockPLL1_150M configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKPLL1_150M_CORE_CLOCK 150000000U /*!< Core clock frequency: 150000000Hz */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockPLL1_150M configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockPLL1_150M(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
#endif /* _CLOCK_CONFIG_H_ */
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
/***********************************************************************************************************************
|
||||
* This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
|
||||
* will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/* clang-format off */
|
||||
/*
|
||||
* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Pins v10.0
|
||||
processor: LPC55S69
|
||||
package_id: LPC55S69JBD100
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 10.0.0
|
||||
pin_labels:
|
||||
- {pin_num: '1', pin_signal: PIO1_4/FC0_SCK/SD0_D0/CTIMER2_MAT1/SCT0_OUT0/FREQME_GPIO_CLK_A, label: LED_BLUE, identifier: LED_BLUE}
|
||||
- {pin_num: '5', pin_signal: PIO1_6/FC0_TXD_SCL_MISO_WS/SD0_D3/CTIMER2_MAT1/SCT_GPI3, label: LED_RED, identifier: LED_RED}
|
||||
- {pin_num: '9', pin_signal: PIO1_7/FC0_RTS_SCL_SSEL1/SD0_D1/CTIMER2_MAT2/SCT_GPI4, label: LED_GREEN, identifier: LED_GREEN}
|
||||
- {pin_num: '10', pin_signal: PIO1_9/FC1_SCK/CT_INP4/SCT0_OUT2/FC4_CTS_SDA_SSEL0/ADC0_12, label: USER_BUTTON, identifier: USER_BUTTON}
|
||||
- {pin_num: '94', pin_signal: PIO0_30/FC0_TXD_SCL_MISO_WS/SD1_D3/CTIMER0_MAT0/SCT0_OUT9/SECURE_GPIO0_30, label: UART_TX, identifier: UART_TX}
|
||||
- {pin_num: '92', pin_signal: PIO0_29/FC0_RXD_SDA_MOSI_DATA/SD1_D2/CTIMER2_MAT3/SCT0_OUT8/CMP0_OUT/PLU_OUT2/SECURE_GPIO0_29, label: UART_RX, identifier: UART_RX}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
|
||||
*/
|
||||
/* clang-format on */
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_iocon.h"
|
||||
#include "pin_mux.h"
|
||||
|
||||
/* FUNCTION ************************************************************************************************************
|
||||
*
|
||||
* Function Name : BOARD_InitBootPins
|
||||
* Description : Calls initialization functions.
|
||||
*
|
||||
* END ****************************************************************************************************************/
|
||||
void BOARD_InitBootPins(void)
|
||||
{
|
||||
BOARD_InitPins();
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
/*
|
||||
* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
BOARD_InitPins:
|
||||
- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'}
|
||||
- pin_list:
|
||||
- {pin_num: '92', peripheral: FLEXCOMM0, signal: RXD_SDA_MOSI_DATA, pin_signal: PIO0_29/FC0_RXD_SDA_MOSI_DATA/SD1_D2/CTIMER2_MAT3/SCT0_OUT8/CMP0_OUT/PLU_OUT2/SECURE_GPIO0_29,
|
||||
direction: INPUT, mode: inactive, slew_rate: standard, invert: disabled, open_drain: disabled}
|
||||
- {pin_num: '94', peripheral: FLEXCOMM0, signal: TXD_SCL_MISO_WS, pin_signal: PIO0_30/FC0_TXD_SCL_MISO_WS/SD1_D3/CTIMER0_MAT0/SCT0_OUT9/SECURE_GPIO0_30, direction: OUTPUT,
|
||||
mode: inactive, slew_rate: standard, invert: disabled, open_drain: disabled}
|
||||
- {pin_num: '1', peripheral: GPIO, signal: 'PIO1, 4', pin_signal: PIO1_4/FC0_SCK/SD0_D0/CTIMER2_MAT1/SCT0_OUT0/FREQME_GPIO_CLK_A, direction: OUTPUT, gpio_init_state: 'true'}
|
||||
- {pin_num: '5', peripheral: GPIO, signal: 'PIO1, 6', pin_signal: PIO1_6/FC0_TXD_SCL_MISO_WS/SD0_D3/CTIMER2_MAT1/SCT_GPI3, direction: OUTPUT, gpio_init_state: 'true'}
|
||||
- {pin_num: '9', peripheral: GPIO, signal: 'PIO1, 7', pin_signal: PIO1_7/FC0_RTS_SCL_SSEL1/SD0_D1/CTIMER2_MAT2/SCT_GPI4, direction: OUTPUT, gpio_init_state: 'true'}
|
||||
- {pin_num: '10', peripheral: GPIO, signal: 'PIO1, 9', pin_signal: PIO1_9/FC1_SCK/CT_INP4/SCT0_OUT2/FC4_CTS_SDA_SSEL0/ADC0_12}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
|
||||
*/
|
||||
/* clang-format on */
|
||||
|
||||
/* FUNCTION ************************************************************************************************************
|
||||
*
|
||||
* Function Name : BOARD_InitPins
|
||||
* Description : Configures pin routing and optionally pin electrical features.
|
||||
*
|
||||
* END ****************************************************************************************************************/
|
||||
/* Function assigned for the Cortex-M33 (Core #0) */
|
||||
void BOARD_InitPins(void)
|
||||
{
|
||||
/* Enables the clock for the I/O controller.: Enable Clock. */
|
||||
CLOCK_EnableClock(kCLOCK_Iocon);
|
||||
|
||||
/* Enables the clock for the GPIO1 module */
|
||||
CLOCK_EnableClock(kCLOCK_Gpio1);
|
||||
|
||||
gpio_pin_config_t LED_BLUE_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 1U
|
||||
};
|
||||
/* Initialize GPIO functionality on pin PIO1_4 (pin 1) */
|
||||
GPIO_PinInit(BOARD_INITPINS_LED_BLUE_GPIO, BOARD_INITPINS_LED_BLUE_PORT, BOARD_INITPINS_LED_BLUE_PIN, &LED_BLUE_config);
|
||||
|
||||
gpio_pin_config_t LED_RED_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 1U
|
||||
};
|
||||
/* Initialize GPIO functionality on pin PIO1_6 (pin 5) */
|
||||
GPIO_PinInit(BOARD_INITPINS_LED_RED_GPIO, BOARD_INITPINS_LED_RED_PORT, BOARD_INITPINS_LED_RED_PIN, &LED_RED_config);
|
||||
|
||||
gpio_pin_config_t LED_GREEN_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 1U
|
||||
};
|
||||
/* Initialize GPIO functionality on pin PIO1_7 (pin 9) */
|
||||
GPIO_PinInit(BOARD_INITPINS_LED_GREEN_GPIO, BOARD_INITPINS_LED_GREEN_PORT, BOARD_INITPINS_LED_GREEN_PIN, &LED_GREEN_config);
|
||||
|
||||
const uint32_t UART_RX = (/* Pin is configured as FC0_RXD_SDA_MOSI_DATA */
|
||||
IOCON_PIO_FUNC1 |
|
||||
/* No addition pin function */
|
||||
IOCON_PIO_MODE_INACT |
|
||||
/* Standard mode, output slew rate control is enabled */
|
||||
IOCON_PIO_SLEW_STANDARD |
|
||||
/* Input function is not inverted */
|
||||
IOCON_PIO_INV_DI |
|
||||
/* Enables digital function */
|
||||
IOCON_PIO_DIGITAL_EN |
|
||||
/* Open drain is disabled */
|
||||
IOCON_PIO_OPENDRAIN_DI);
|
||||
/* PORT0 PIN29 (coords: 92) is configured as FC0_RXD_SDA_MOSI_DATA */
|
||||
IOCON_PinMuxSet(IOCON, BOARD_INITPINS_UART_RX_PORT, BOARD_INITPINS_UART_RX_PIN, UART_RX);
|
||||
|
||||
const uint32_t UART_TX = (/* Pin is configured as FC0_TXD_SCL_MISO_WS */
|
||||
IOCON_PIO_FUNC1 |
|
||||
/* No addition pin function */
|
||||
IOCON_PIO_MODE_INACT |
|
||||
/* Standard mode, output slew rate control is enabled */
|
||||
IOCON_PIO_SLEW_STANDARD |
|
||||
/* Input function is not inverted */
|
||||
IOCON_PIO_INV_DI |
|
||||
/* Enables digital function */
|
||||
IOCON_PIO_DIGITAL_EN |
|
||||
/* Open drain is disabled */
|
||||
IOCON_PIO_OPENDRAIN_DI);
|
||||
/* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
|
||||
IOCON_PinMuxSet(IOCON, BOARD_INITPINS_UART_TX_PORT, BOARD_INITPINS_UART_TX_PIN, UART_TX);
|
||||
|
||||
IOCON->PIO[1][4] = ((IOCON->PIO[1][4] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT14 (pin 1) is configured as PIO1_4. */
|
||||
| IOCON_PIO_FUNC(PIO1_4_FUNC_ALT0)
|
||||
|
||||
/* Select Digital mode.
|
||||
* : Enable Digital mode.
|
||||
* Digital input is enabled. */
|
||||
| IOCON_PIO_DIGIMODE(PIO1_4_DIGIMODE_DIGITAL));
|
||||
|
||||
IOCON->PIO[1][6] = ((IOCON->PIO[1][6] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT16 (pin 5) is configured as PIO1_6. */
|
||||
| IOCON_PIO_FUNC(PIO1_6_FUNC_ALT0)
|
||||
|
||||
/* Select Digital mode.
|
||||
* : Enable Digital mode.
|
||||
* Digital input is enabled. */
|
||||
| IOCON_PIO_DIGIMODE(PIO1_6_DIGIMODE_DIGITAL));
|
||||
|
||||
IOCON->PIO[1][7] = ((IOCON->PIO[1][7] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT17 (pin 9) is configured as PIO1_7. */
|
||||
| IOCON_PIO_FUNC(PIO1_7_FUNC_ALT0)
|
||||
|
||||
/* Select Digital mode.
|
||||
* : Enable Digital mode.
|
||||
* Digital input is enabled. */
|
||||
| IOCON_PIO_DIGIMODE(PIO1_7_DIGIMODE_DIGITAL));
|
||||
|
||||
if (Chip_GetVersion()==1)
|
||||
{
|
||||
IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT19 (pin 10) is configured as PIO1_9. */
|
||||
| IOCON_PIO_FUNC(PIO1_9_FUNC_ALT0)
|
||||
|
||||
/* Select Digital mode.
|
||||
* : Enable Digital mode.
|
||||
* Digital input is enabled. */
|
||||
| IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));
|
||||
}
|
||||
else
|
||||
{
|
||||
IOCON->PIO[1][9] = ((IOCON->PIO[1][9] &
|
||||
/* Mask bits to zero which are setting */
|
||||
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
|
||||
|
||||
/* Selects pin function.
|
||||
* : PORT19 (pin 10) is configured as PIO1_9. */
|
||||
| IOCON_PIO_FUNC(PIO1_9_FUNC_ALT0)
|
||||
|
||||
/* Select Digital mode.
|
||||
* : Enable Digital mode.
|
||||
* Digital input is enabled. */
|
||||
| IOCON_PIO_DIGIMODE(PIO1_9_DIGIMODE_DIGITAL));
|
||||
}
|
||||
}
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
**********************************************************************************************************************/
|
||||
@@ -0,0 +1,118 @@
|
||||
/***********************************************************************************************************************
|
||||
* This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
|
||||
* will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef _PIN_MUX_H_
|
||||
#define _PIN_MUX_H_
|
||||
|
||||
/*!
|
||||
* @addtogroup pin_mux
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* API
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Calls initialization functions.
|
||||
*
|
||||
*/
|
||||
void BOARD_InitBootPins(void);
|
||||
|
||||
#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
|
||||
#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
|
||||
#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
|
||||
#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
|
||||
#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
|
||||
#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
|
||||
#define PIO1_4_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Digital mode.: Enable Digital mode. Digital input is enabled. */
|
||||
#define PIO1_4_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
#define PIO1_6_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Digital mode.: Enable Digital mode. Digital input is enabled. */
|
||||
#define PIO1_6_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
#define PIO1_7_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Digital mode.: Enable Digital mode. Digital input is enabled. */
|
||||
#define PIO1_7_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
#define PIO1_9_DIGIMODE_DIGITAL 0x01u /*!<@brief Select Digital mode.: Enable Digital mode. Digital input is enabled. */
|
||||
#define PIO1_9_FUNC_ALT0 0x00u /*!<@brief Selects pin function.: Alternative connection 0. */
|
||||
|
||||
/*! @name PIO0_29 (number 92), UART_RX
|
||||
@{ */
|
||||
#define BOARD_INITPINS_UART_RX_PORT 0U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_UART_RX_PIN 29U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_UART_RX_PIN_MASK (1U << 29U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO0_30 (number 94), UART_TX
|
||||
@{ */
|
||||
#define BOARD_INITPINS_UART_TX_PORT 0U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_UART_TX_PIN 30U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_UART_TX_PIN_MASK (1U << 30U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO1_4 (number 1), LED_BLUE
|
||||
@{ */
|
||||
|
||||
/* Symbols to be used with GPIO driver */
|
||||
#define BOARD_INITPINS_LED_BLUE_GPIO GPIO /*!<@brief GPIO peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_BLUE_GPIO_PIN_MASK (1U << 4U) /*!<@brief GPIO pin mask */
|
||||
#define BOARD_INITPINS_LED_BLUE_PORT 1U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_BLUE_PIN 4U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_LED_BLUE_PIN_MASK (1U << 4U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO1_6 (number 5), LED_RED
|
||||
@{ */
|
||||
|
||||
/* Symbols to be used with GPIO driver */
|
||||
#define BOARD_INITPINS_LED_RED_GPIO GPIO /*!<@brief GPIO peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_RED_GPIO_PIN_MASK (1U << 6U) /*!<@brief GPIO pin mask */
|
||||
#define BOARD_INITPINS_LED_RED_PORT 1U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_RED_PIN 6U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_LED_RED_PIN_MASK (1U << 6U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO1_7 (number 9), LED_GREEN
|
||||
@{ */
|
||||
|
||||
/* Symbols to be used with GPIO driver */
|
||||
#define BOARD_INITPINS_LED_GREEN_GPIO GPIO /*!<@brief GPIO peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_GREEN_GPIO_PIN_MASK (1U << 7U) /*!<@brief GPIO pin mask */
|
||||
#define BOARD_INITPINS_LED_GREEN_PORT 1U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_LED_GREEN_PIN 7U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_LED_GREEN_PIN_MASK (1U << 7U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*! @name PIO1_9 (number 10), USER_BUTTON
|
||||
@{ */
|
||||
|
||||
/* Symbols to be used with GPIO driver */
|
||||
#define BOARD_INITPINS_USER_BUTTON_GPIO GPIO /*!<@brief GPIO peripheral base pointer */
|
||||
#define BOARD_INITPINS_USER_BUTTON_GPIO_PIN_MASK (1U << 9U) /*!<@brief GPIO pin mask */
|
||||
#define BOARD_INITPINS_USER_BUTTON_PORT 1U /*!<@brief PORT peripheral base pointer */
|
||||
#define BOARD_INITPINS_USER_BUTTON_PIN 9U /*!<@brief PORT pin number */
|
||||
#define BOARD_INITPINS_USER_BUTTON_PIN_MASK (1U << 9U) /*!<@brief PORT pin mask */
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @brief Configures pin routing and optionally pin electrical features.
|
||||
*
|
||||
*/
|
||||
void BOARD_InitPins(void); /* Function assigned for the Cortex-M33 (Core #0) */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _PIN_MUX_H_ */
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
**********************************************************************************************************************/
|
||||
+493
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright 2018-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Include
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
#include "fsl_component_generic_list.h"
|
||||
|
||||
#if defined(OSA_USED)
|
||||
#include "fsl_os_abstraction.h"
|
||||
#if (defined(USE_RTOS) && (USE_RTOS > 0U))
|
||||
#define LIST_ENTER_CRITICAL() \
|
||||
OSA_SR_ALLOC(); \
|
||||
OSA_ENTER_CRITICAL()
|
||||
#define LIST_EXIT_CRITICAL() OSA_EXIT_CRITICAL()
|
||||
#else
|
||||
#define LIST_ENTER_CRITICAL()
|
||||
#define LIST_EXIT_CRITICAL()
|
||||
#endif
|
||||
#else
|
||||
#define LIST_ENTER_CRITICAL() uint32_t regPrimask = DisableGlobalIRQ();
|
||||
#define LIST_EXIT_CRITICAL() EnableGlobalIRQ(regPrimask);
|
||||
#endif
|
||||
|
||||
static list_status_t LIST_Error_Check(list_handle_t list, list_element_handle_t newElement)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
#if (defined(GENERIC_LIST_DUPLICATED_CHECKING) && (GENERIC_LIST_DUPLICATED_CHECKING > 0U))
|
||||
list_element_handle_t element = list->head;
|
||||
#endif
|
||||
if ((list->max != 0U) && (list->max == list->size))
|
||||
{
|
||||
listStatus = kLIST_Full; /*List is full*/
|
||||
}
|
||||
#if (defined(GENERIC_LIST_DUPLICATED_CHECKING) && (GENERIC_LIST_DUPLICATED_CHECKING > 0U))
|
||||
else
|
||||
{
|
||||
while (element != NULL) /*Scan list*/
|
||||
{
|
||||
/* Determine if element is duplicated */
|
||||
if (element == newElement)
|
||||
{
|
||||
listStatus = kLIST_DuplicateError;
|
||||
break;
|
||||
}
|
||||
element = element->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public functions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
/*! *********************************************************************************
|
||||
* \brief Initialises the list descriptor.
|
||||
*
|
||||
* \param[in] list - LIST_ handle to init.
|
||||
* max - Maximum number of elements in list. 0 for unlimited.
|
||||
*
|
||||
* \return void.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
void LIST_Init(list_handle_t list, uint32_t max)
|
||||
{
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
list->max = (uint16_t)max;
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the list that contains the given element.
|
||||
*
|
||||
* \param[in] element - Handle of the element.
|
||||
*
|
||||
* \return NULL if element is orphan.
|
||||
* Handle of the list the element is inserted into.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_handle_t LIST_GetList(list_element_handle_t element)
|
||||
{
|
||||
return element->list;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links element to the tail of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to insert into.
|
||||
* element - element to add
|
||||
*
|
||||
* \return kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddTail(list_handle_t list, list_element_handle_t element)
|
||||
{
|
||||
LIST_ENTER_CRITICAL();
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
|
||||
listStatus = LIST_Error_Check(list, element);
|
||||
if (listStatus == kLIST_Ok) /* Avoiding list status error */
|
||||
{
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->head = element;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->tail->next = element;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
element->prev = list->tail;
|
||||
#endif
|
||||
element->list = list;
|
||||
element->next = NULL;
|
||||
list->tail = element;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
LIST_EXIT_CRITICAL();
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links element to the head of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to insert into.
|
||||
* element - element to add
|
||||
*
|
||||
* \return kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddHead(list_handle_t list, list_element_handle_t element)
|
||||
{
|
||||
LIST_ENTER_CRITICAL();
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
|
||||
listStatus = LIST_Error_Check(list, element);
|
||||
if (listStatus == kLIST_Ok) /* Avoiding list status error */
|
||||
{
|
||||
/* Links element to the head of the list */
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->tail = element;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
else
|
||||
{
|
||||
list->head->prev = element;
|
||||
}
|
||||
element->prev = NULL;
|
||||
#endif
|
||||
element->list = list;
|
||||
element->next = list->head;
|
||||
list->head = element;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
LIST_EXIT_CRITICAL();
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Unlinks element from the head of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to remove from.
|
||||
*
|
||||
* \return NULL if list is empty.
|
||||
* ID of removed element(pointer) if removal was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_RemoveHead(list_handle_t list)
|
||||
{
|
||||
list_element_handle_t element;
|
||||
|
||||
LIST_ENTER_CRITICAL();
|
||||
|
||||
if ((NULL == list) || (list->size == 0U))
|
||||
{
|
||||
element = NULL; /*LIST_ is empty*/
|
||||
}
|
||||
else
|
||||
{
|
||||
element = list->head;
|
||||
list->size--;
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->tail = NULL;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
else
|
||||
{
|
||||
element->next->prev = NULL;
|
||||
}
|
||||
#endif
|
||||
element->list = NULL;
|
||||
list->head = element->next; /*Is NULL if element is head*/
|
||||
}
|
||||
|
||||
LIST_EXIT_CRITICAL();
|
||||
return element;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets head element ID.
|
||||
*
|
||||
* \param[in] list - ID of list.
|
||||
*
|
||||
* \return NULL if list is empty.
|
||||
* ID of head element if list is not empty.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetHead(list_handle_t list)
|
||||
{
|
||||
return list->head;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets next element ID.
|
||||
*
|
||||
* \param[in] element - ID of the element.
|
||||
*
|
||||
* \return NULL if element is tail.
|
||||
* ID of next element if exists.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetNext(list_element_handle_t element)
|
||||
{
|
||||
return element->next;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets previous element ID.
|
||||
*
|
||||
* \param[in] element - ID of the element.
|
||||
*
|
||||
* \return NULL if element is head.
|
||||
* ID of previous element if exists.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetPrev(list_element_handle_t element)
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
return NULL;
|
||||
#else
|
||||
return element->prev;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Unlinks an element from its list.
|
||||
*
|
||||
* \param[in] element - ID of the element to remove.
|
||||
*
|
||||
* \return kLIST_OrphanElement if element is not part of any list.
|
||||
* kLIST_Ok if removal was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_RemoveElement(list_element_handle_t element)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
LIST_ENTER_CRITICAL();
|
||||
|
||||
if (element->list == NULL)
|
||||
{
|
||||
listStatus = kLIST_OrphanElement; /*Element was previusly removed or never added*/
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
list_element_handle_t element_list = element->list->head;
|
||||
while (NULL != element_list)
|
||||
{
|
||||
if (element->list->head == element)
|
||||
{
|
||||
element->list->head = element_list->next;
|
||||
break;
|
||||
}
|
||||
if (element_list->next == element)
|
||||
{
|
||||
element_list->next = element->next;
|
||||
break;
|
||||
}
|
||||
element_list = element_list->next;
|
||||
}
|
||||
#else
|
||||
if (element->prev == NULL) /*Element is head or solo*/
|
||||
{
|
||||
element->list->head = element->next; /*is null if solo*/
|
||||
}
|
||||
if (element->next == NULL) /*Element is tail or solo*/
|
||||
{
|
||||
element->list->tail = element->prev; /*is null if solo*/
|
||||
}
|
||||
if (element->prev != NULL) /*Element is not head*/
|
||||
{
|
||||
element->prev->next = element->next;
|
||||
}
|
||||
if (element->next != NULL) /*Element is not tail*/
|
||||
{
|
||||
element->next->prev = element->prev;
|
||||
}
|
||||
#endif
|
||||
element->list->size--;
|
||||
element->list = NULL;
|
||||
}
|
||||
|
||||
LIST_EXIT_CRITICAL();
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links an element in the previous position relative to a given member
|
||||
* of a list.
|
||||
*
|
||||
* \param[in] element - ID of a member of a list.
|
||||
* newElement - new element to insert before the given member.
|
||||
*
|
||||
* \return kLIST_OrphanElement if element is not part of any list.
|
||||
* kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddPrevElement(list_element_handle_t element, list_element_handle_t newElement)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
LIST_ENTER_CRITICAL();
|
||||
|
||||
if (element->list == NULL)
|
||||
{
|
||||
listStatus = kLIST_OrphanElement; /*Element was previusly removed or never added*/
|
||||
}
|
||||
else
|
||||
{
|
||||
listStatus = LIST_Error_Check(element->list, newElement);
|
||||
if (listStatus == kLIST_Ok)
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
list_element_handle_t element_list = element->list->head;
|
||||
while (NULL != element_list)
|
||||
{
|
||||
if ((element_list->next == element) || (element_list == element))
|
||||
{
|
||||
if (element_list == element)
|
||||
{
|
||||
element->list->head = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
element_list->next = newElement;
|
||||
}
|
||||
newElement->list = element->list;
|
||||
newElement->next = element;
|
||||
element->list->size++;
|
||||
break;
|
||||
}
|
||||
element_list = element_list->next;
|
||||
}
|
||||
|
||||
#else
|
||||
if (element->prev == NULL) /*Element is list head*/
|
||||
{
|
||||
element->list->head = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
element->prev->next = newElement;
|
||||
}
|
||||
newElement->list = element->list;
|
||||
element->list->size++;
|
||||
newElement->next = element;
|
||||
newElement->prev = element->prev;
|
||||
element->prev = newElement;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
LIST_EXIT_CRITICAL();
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the current size of a list.
|
||||
*
|
||||
* \param[in] list - ID of the list.
|
||||
*
|
||||
* \return Current size of the list.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
uint32_t LIST_GetSize(list_handle_t list)
|
||||
{
|
||||
return list->size;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the number of free places in the list.
|
||||
*
|
||||
* \param[in] list - ID of the list.
|
||||
*
|
||||
* \return Available size of the list.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
uint32_t LIST_GetAvailableSize(list_handle_t list)
|
||||
{
|
||||
return ((uint32_t)list->max - (uint32_t)list->size); /*Gets the number of free places in the list*/
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright 2018-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _GENERIC_LIST_H_
|
||||
#define _GENERIC_LIST_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
/*!
|
||||
* @addtogroup GenericList
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**********************************************************************************
|
||||
* Include
|
||||
***********************************************************************************/
|
||||
|
||||
/**********************************************************************************
|
||||
* Public macro definitions
|
||||
***********************************************************************************/
|
||||
/*! @brief Definition to determine whether use list light. */
|
||||
#ifndef GENERIC_LIST_LIGHT
|
||||
#define GENERIC_LIST_LIGHT (1)
|
||||
#endif
|
||||
|
||||
/*! @brief Definition to determine whether enable list duplicated checking. */
|
||||
#ifndef GENERIC_LIST_DUPLICATED_CHECKING
|
||||
#define GENERIC_LIST_DUPLICATED_CHECKING (0)
|
||||
#endif
|
||||
|
||||
/**********************************************************************************
|
||||
* Public type definitions
|
||||
***********************************************************************************/
|
||||
/*! @brief The list status */
|
||||
typedef enum _list_status
|
||||
{
|
||||
kLIST_Ok = kStatus_Success, /*!< Success */
|
||||
kLIST_DuplicateError = MAKE_STATUS(kStatusGroup_LIST, 1), /*!< Duplicate Error */
|
||||
kLIST_Full = MAKE_STATUS(kStatusGroup_LIST, 2), /*!< FULL */
|
||||
kLIST_Empty = MAKE_STATUS(kStatusGroup_LIST, 3), /*!< Empty */
|
||||
kLIST_OrphanElement = MAKE_STATUS(kStatusGroup_LIST, 4), /*!< Orphan Element */
|
||||
kLIST_NotSupport = MAKE_STATUS(kStatusGroup_LIST, 5), /*!< Not Support */
|
||||
} list_status_t;
|
||||
|
||||
/*! @brief The list structure*/
|
||||
typedef struct list_label
|
||||
{
|
||||
struct list_element_tag *head; /*!< list head */
|
||||
struct list_element_tag *tail; /*!< list tail */
|
||||
uint16_t size; /*!< list size */
|
||||
uint16_t max; /*!< list max number of elements */
|
||||
} list_label_t, *list_handle_t;
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
/*! @brief The list element*/
|
||||
typedef struct list_element_tag
|
||||
{
|
||||
struct list_element_tag *next; /*!< next list element */
|
||||
struct list_label *list; /*!< pointer to the list */
|
||||
} list_element_t, *list_element_handle_t;
|
||||
#else
|
||||
/*! @brief The list element*/
|
||||
typedef struct list_element_tag
|
||||
{
|
||||
struct list_element_tag *next; /*!< next list element */
|
||||
struct list_element_tag *prev; /*!< previous list element */
|
||||
struct list_label *list; /*!< pointer to the list */
|
||||
} list_element_t, *list_element_handle_t;
|
||||
#endif
|
||||
/**********************************************************************************
|
||||
* Public prototypes
|
||||
***********************************************************************************/
|
||||
/**********************************************************************************
|
||||
* API
|
||||
**********************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* _cplusplus */
|
||||
/*!
|
||||
* @brief Initialize the list.
|
||||
*
|
||||
* This function initialize the list.
|
||||
*
|
||||
* @param list - List handle to initialize.
|
||||
* @param max - Maximum number of elements in list. 0 for unlimited.
|
||||
*/
|
||||
void LIST_Init(list_handle_t list, uint32_t max);
|
||||
|
||||
/*!
|
||||
* @brief Gets the list that contains the given element.
|
||||
*
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
* @retval NULL if element is orphan, Handle of the list the element is inserted into.
|
||||
*/
|
||||
list_handle_t LIST_GetList(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links element to the head of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
* @param element - Handle of the element.
|
||||
* @retval kLIST_Full if list is full, kLIST_Ok if insertion was successful.
|
||||
*/
|
||||
list_status_t LIST_AddHead(list_handle_t list, list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links element to the tail of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
* @param element - Handle of the element.
|
||||
* @retval kLIST_Full if list is full, kLIST_Ok if insertion was successful.
|
||||
*/
|
||||
list_status_t LIST_AddTail(list_handle_t list, list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Unlinks element from the head of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_RemoveHead(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets head element handle.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetHead(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets next element handle for given element handle.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetNext(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Gets previous element handle for given element handle.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetPrev(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Unlinks an element from its list.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval kLIST_OrphanElement if element is not part of any list.
|
||||
* @retval kLIST_Ok if removal was successful.
|
||||
*/
|
||||
list_status_t LIST_RemoveElement(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links an element in the previous position relative to a given member of a list.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
* @param newElement - New element to insert before the given member.
|
||||
*
|
||||
* @retval kLIST_OrphanElement if element is not part of any list.
|
||||
* @retval kLIST_Ok if removal was successful.
|
||||
*/
|
||||
list_status_t LIST_AddPrevElement(list_element_handle_t element, list_element_handle_t newElement);
|
||||
|
||||
/*!
|
||||
* @brief Gets the current size of a list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval Current size of the list.
|
||||
*/
|
||||
uint32_t LIST_GetSize(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets the number of free places in the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval Available size of the list.
|
||||
*/
|
||||
uint32_t LIST_GetAvailableSize(list_handle_t list);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*! @}*/
|
||||
#endif /*_GENERIC_LIST_H_*/
|
||||
+1733
File diff suppressed because it is too large
Load Diff
+772
File diff suppressed because it is too large
Load Diff
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2019-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __SERIAL_PORT_INTERNAL_H__
|
||||
#define __SERIAL_PORT_INTERNAL_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* _cplusplus */
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
|
||||
serial_manager_status_t Serial_UartInit(serial_handle_t serialHandle, void *serialConfig);
|
||||
serial_manager_status_t Serial_UartDeinit(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_UartWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_UartWriteBlocking(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_MODE */
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE) && (SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE > 0U))
|
||||
serial_manager_status_t Serial_UartRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#endif
|
||||
#else
|
||||
serial_manager_status_t Serial_UartRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_UartCancelWrite(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_UartInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
serial_manager_status_t Serial_UartInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
void Serial_UartIsrFunction(serial_handle_t serialHandle);
|
||||
#endif
|
||||
serial_manager_status_t Serial_UartEnterLowpower(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_UartExitLowpower(serial_handle_t serialHandle);
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_RPMSG) && (SERIAL_PORT_TYPE_RPMSG > 0U))
|
||||
serial_manager_status_t Serial_RpmsgInit(serial_handle_t serialHandle, void *serialConfig);
|
||||
serial_manager_status_t Serial_RpmsgDeinit(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_RpmsgWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
serial_manager_status_t Serial_RpmsgWriteBlocking(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_RpmsgRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_RpmsgCancelWrite(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_RpmsgInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
serial_manager_status_t Serial_RpmsgInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
#endif
|
||||
serial_manager_status_t Serial_RpmsgEnterLowpower(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_RpmsgExitLowpower(serial_handle_t serialHandle);
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
|
||||
serial_manager_status_t Serial_UsbCdcInit(serial_handle_t serialHandle, void *config);
|
||||
serial_manager_status_t Serial_UsbCdcDeinit(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_UsbCdcWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
serial_manager_status_t Serial_UsbCdcRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
serial_manager_status_t Serial_UsbCdcCancelWrite(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_UsbCdcInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
serial_manager_status_t Serial_UsbCdcInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
void Serial_UsbCdcIsrFunction(serial_handle_t serialHandle);
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
|
||||
serial_manager_status_t Serial_SwoInit(serial_handle_t serialHandle, void *config);
|
||||
serial_manager_status_t Serial_SwoDeinit(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_SwoWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_SwoRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
#endif
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_SwoCancelWrite(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_SwoInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
serial_manager_status_t Serial_SwoInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
void Serial_SwoIsrFunction(serial_handle_t serialHandle);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_VIRTUAL) && (SERIAL_PORT_TYPE_VIRTUAL > 0U))
|
||||
serial_manager_status_t Serial_PortVirtualInit(serial_handle_t serialHandle, void *config);
|
||||
serial_manager_status_t Serial_PortVirtualDeinit(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_PortVirtualWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
serial_manager_status_t Serial_PortVirtualRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
|
||||
serial_manager_status_t Serial_PortVirtualCancelWrite(serial_handle_t serialHandle);
|
||||
serial_manager_status_t Serial_PortVirtualInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
serial_manager_status_t Serial_PortVirtualInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam);
|
||||
void Serial_PortVirtualIsrFunction(serial_handle_t serialHandle);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SERIAL_PORT_INTERNAL_H__ */
|
||||
+460
@@ -0,0 +1,460 @@
|
||||
/*
|
||||
* Copyright 2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_component_serial_manager.h"
|
||||
#include "fsl_component_serial_port_internal.h"
|
||||
|
||||
#if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
|
||||
#include "fsl_adapter_uart.h"
|
||||
|
||||
#include "fsl_component_serial_port_uart.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#ifndef NDEBUG
|
||||
#if (defined(DEBUG_CONSOLE_ASSERT_DISABLE) && (DEBUG_CONSOLE_ASSERT_DISABLE > 0U))
|
||||
#undef assert
|
||||
#define assert(n)
|
||||
#else
|
||||
/* MISRA C-2012 Rule 17.2 */
|
||||
#undef assert
|
||||
#define assert(n) \
|
||||
while (!(n)) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#define SERIAL_PORT_UART_RECEIVE_DATA_LENGTH 1U
|
||||
#define SERIAL_MANAGER_BLOCK_OFFSET (12U)
|
||||
typedef struct _serial_uart_send_state
|
||||
{
|
||||
uint8_t *buffer;
|
||||
uint32_t length;
|
||||
serial_manager_callback_t callback;
|
||||
void *callbackParam;
|
||||
volatile uint8_t busy;
|
||||
} serial_uart_send_state_t;
|
||||
|
||||
typedef struct _serial_uart_recv_state
|
||||
{
|
||||
serial_manager_callback_t callback;
|
||||
void *callbackParam;
|
||||
volatile uint8_t busy;
|
||||
volatile uint8_t rxEnable;
|
||||
uint8_t readBuffer[SERIAL_PORT_UART_RECEIVE_DATA_LENGTH];
|
||||
} serial_uart_recv_state_t;
|
||||
typedef struct _serial_uart_block_state
|
||||
{
|
||||
UART_HANDLE_DEFINE(usartHandleBuffer);
|
||||
} serial_uart_block_state_t;
|
||||
#endif
|
||||
|
||||
typedef struct _serial_uart_state
|
||||
{
|
||||
UART_HANDLE_DEFINE(usartHandleBuffer);
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_uart_send_state_t tx;
|
||||
serial_uart_recv_state_t rx;
|
||||
#endif
|
||||
} serial_uart_state_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
static serial_manager_status_t Serial_UartEnableReceiving(serial_uart_state_t *serialUartHandle)
|
||||
{
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
hal_uart_transfer_t transfer;
|
||||
#endif
|
||||
if (1U == serialUartHandle->rx.rxEnable)
|
||||
{
|
||||
serialUartHandle->rx.busy = 1U;
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
transfer.data = &serialUartHandle->rx.readBuffer[0];
|
||||
transfer.dataSize = sizeof(serialUartHandle->rx.readBuffer);
|
||||
if (kStatus_HAL_UartSuccess !=
|
||||
HAL_UartTransferReceiveNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer))
|
||||
#else
|
||||
if (kStatus_HAL_UartSuccess !=
|
||||
HAL_UartReceiveNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
|
||||
&serialUartHandle->rx.readBuffer[0], sizeof(serialUartHandle->rx.readBuffer)))
|
||||
#endif
|
||||
{
|
||||
serialUartHandle->rx.busy = 0U;
|
||||
return kStatus_SerialManager_Error;
|
||||
}
|
||||
}
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
/* UART user callback */
|
||||
static void Serial_UartCallback(hal_uart_handle_t handle, hal_uart_status_t status, void *userData)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
serial_manager_callback_message_t msg;
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
hal_uart_transfer_t transfer;
|
||||
#endif
|
||||
|
||||
assert(userData);
|
||||
serialUartHandle = (serial_uart_state_t *)userData;
|
||||
|
||||
if ((hal_uart_status_t)kStatus_HAL_UartRxIdle == status)
|
||||
{
|
||||
if ((NULL != serialUartHandle->rx.callback))
|
||||
{
|
||||
msg.buffer = &serialUartHandle->rx.readBuffer[0];
|
||||
msg.length = sizeof(serialUartHandle->rx.readBuffer);
|
||||
serialUartHandle->rx.callback(serialUartHandle->rx.callbackParam, &msg, kStatus_SerialManager_Success);
|
||||
}
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
transfer.data = &serialUartHandle->rx.readBuffer[0];
|
||||
transfer.dataSize = sizeof(serialUartHandle->rx.readBuffer);
|
||||
serialUartHandle->rx.busy = 0U;
|
||||
if (kStatus_HAL_UartSuccess ==
|
||||
HAL_UartTransferReceiveNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer))
|
||||
#else
|
||||
if ((hal_uart_status_t)kStatus_HAL_UartSuccess ==
|
||||
HAL_UartReceiveNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
|
||||
&serialUartHandle->rx.readBuffer[0], sizeof(serialUartHandle->rx.readBuffer)))
|
||||
#endif
|
||||
{
|
||||
serialUartHandle->rx.busy = 1U;
|
||||
}
|
||||
}
|
||||
else if ((hal_uart_status_t)kStatus_HAL_UartTxIdle == status)
|
||||
{
|
||||
if (0U != serialUartHandle->tx.busy)
|
||||
{
|
||||
serialUartHandle->tx.busy = 0U;
|
||||
if ((NULL != serialUartHandle->tx.callback))
|
||||
{
|
||||
msg.buffer = serialUartHandle->tx.buffer;
|
||||
msg.length = serialUartHandle->tx.length;
|
||||
serialUartHandle->tx.callback(serialUartHandle->tx.callbackParam, &msg, kStatus_SerialManager_Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
serial_manager_status_t Serial_UartInit(serial_handle_t serialHandle, void *serialConfig)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_port_uart_config_t *uartConfig = (serial_port_uart_config_t *)serialConfig;
|
||||
#endif
|
||||
serial_manager_status_t serialManagerStatus = kStatus_SerialManager_Success;
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
#if 0 /* Not used below! */
|
||||
hal_uart_transfer_t transfer;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
assert(serialConfig);
|
||||
assert(serialHandle);
|
||||
assert(SERIAL_PORT_UART_HANDLE_SIZE >= sizeof(serial_uart_state_t));
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
serialManagerStatus = (serial_manager_status_t)HAL_UartInit(
|
||||
((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), (const hal_uart_config_t *)serialConfig);
|
||||
assert(kStatus_SerialManager_Success == serialManagerStatus);
|
||||
(void)serialManagerStatus;
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE) && (SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE > 0U))
|
||||
serial_manager_type_t type = *(serial_manager_type_t *)((uint32_t)serialHandle - SERIAL_MANAGER_BLOCK_OFFSET);
|
||||
if (type == kSerialManager_Blocking)
|
||||
{
|
||||
return serialManagerStatus;
|
||||
}
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE */
|
||||
serialUartHandle->rx.rxEnable = uartConfig->enableRx;
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
|
||||
(void)HAL_UartTransferInstallCallback(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
|
||||
Serial_UartCallback, serialUartHandle);
|
||||
#else
|
||||
(void)HAL_UartInstallCallback(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), Serial_UartCallback,
|
||||
serialUartHandle);
|
||||
#endif
|
||||
#endif
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serialManagerStatus = Serial_UartEnableReceiving(serialUartHandle);
|
||||
#endif
|
||||
|
||||
return serialManagerStatus;
|
||||
}
|
||||
|
||||
serial_manager_status_t Serial_UartDeinit(serial_handle_t serialHandle)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
(void)HAL_UartTransferAbortReceive(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
#else
|
||||
(void)HAL_UartAbortReceive(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
#endif
|
||||
#endif
|
||||
(void)HAL_UartDeinit(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serialUartHandle->tx.busy = 0U;
|
||||
serialUartHandle->rx.busy = 0U;
|
||||
#endif
|
||||
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
|
||||
serial_manager_status_t Serial_UartWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
hal_uart_status_t uartstatus;
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
hal_uart_transfer_t transfer;
|
||||
#endif
|
||||
|
||||
assert(serialHandle);
|
||||
assert(buffer);
|
||||
assert(length);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE) && (SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE > 0U))
|
||||
serial_manager_type_t type = *(serial_manager_type_t *)((uint32_t)serialHandle - SERIAL_MANAGER_BLOCK_OFFSET);
|
||||
if (type == kSerialManager_Blocking)
|
||||
{
|
||||
return (serial_manager_status_t)HAL_UartSendBlocking(
|
||||
((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), buffer, length);
|
||||
}
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE */
|
||||
if (0U != serialUartHandle->tx.busy)
|
||||
{
|
||||
return kStatus_SerialManager_Busy;
|
||||
}
|
||||
serialUartHandle->tx.busy = 1U;
|
||||
|
||||
serialUartHandle->tx.buffer = buffer;
|
||||
serialUartHandle->tx.length = length;
|
||||
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
transfer.data = buffer;
|
||||
transfer.dataSize = length;
|
||||
uartstatus =
|
||||
HAL_UartTransferSendNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer);
|
||||
#else
|
||||
|
||||
uartstatus = HAL_UartSendNonBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), buffer, length);
|
||||
#endif
|
||||
assert(kStatus_HAL_UartSuccess == uartstatus);
|
||||
(void)uartstatus;
|
||||
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
serial_manager_status_t Serial_UartWriteBlocking(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
assert(buffer);
|
||||
assert(length);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
return (serial_manager_status_t)HAL_UartSendBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
|
||||
buffer, length);
|
||||
}
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE) && (SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE > 0U))
|
||||
serial_manager_status_t Serial_UartRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
assert(buffer);
|
||||
assert(length);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
return (serial_manager_status_t)HAL_UartReceiveBlocking(
|
||||
((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), buffer, length);
|
||||
}
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_DUAL_MODE */
|
||||
#else
|
||||
|
||||
serial_manager_status_t Serial_UartWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
assert(buffer);
|
||||
assert(length);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
return (serial_manager_status_t)HAL_UartSendBlocking(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
|
||||
buffer, length);
|
||||
}
|
||||
|
||||
serial_manager_status_t Serial_UartRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
assert(buffer);
|
||||
assert(length);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
return (serial_manager_status_t)HAL_UartReceiveBlocking(
|
||||
((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), buffer, length);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_status_t Serial_UartCancelWrite(serial_handle_t serialHandle)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
serial_manager_callback_message_t msg;
|
||||
uint32_t primask;
|
||||
uint8_t isBusy = 0U;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
primask = DisableGlobalIRQ();
|
||||
isBusy = serialUartHandle->tx.busy;
|
||||
serialUartHandle->tx.busy = 0U;
|
||||
EnableGlobalIRQ(primask);
|
||||
|
||||
#if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
|
||||
(void)HAL_UartTransferAbortSend(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
#else
|
||||
(void)HAL_UartAbortSend(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
#endif
|
||||
if (0U != isBusy)
|
||||
{
|
||||
if ((NULL != serialUartHandle->tx.callback))
|
||||
{
|
||||
msg.buffer = serialUartHandle->tx.buffer;
|
||||
msg.length = serialUartHandle->tx.length;
|
||||
serialUartHandle->tx.callback(serialUartHandle->tx.callbackParam, &msg, kStatus_SerialManager_Canceled);
|
||||
}
|
||||
}
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
serial_manager_status_t Serial_UartInstallTxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
serialUartHandle->tx.callback = callback;
|
||||
serialUartHandle->tx.callbackParam = callbackParam;
|
||||
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
serial_manager_status_t Serial_UartInstallRxCallback(serial_handle_t serialHandle,
|
||||
serial_manager_callback_t callback,
|
||||
void *callbackParam)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
serialUartHandle->rx.callback = callback;
|
||||
serialUartHandle->rx.callbackParam = callbackParam;
|
||||
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
void Serial_UartIsrFunction(serial_handle_t serialHandle)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
HAL_UartIsrFunction(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
}
|
||||
#endif
|
||||
|
||||
serial_manager_status_t Serial_UartEnterLowpower(serial_handle_t serialHandle)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
hal_uart_status_t uartstatus;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
uartstatus = HAL_UartEnterLowpower(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
assert(kStatus_HAL_UartSuccess == uartstatus);
|
||||
(void)uartstatus;
|
||||
|
||||
return kStatus_SerialManager_Success;
|
||||
}
|
||||
|
||||
serial_manager_status_t Serial_UartExitLowpower(serial_handle_t serialHandle)
|
||||
{
|
||||
serial_uart_state_t *serialUartHandle;
|
||||
serial_manager_status_t status = kStatus_SerialManager_Success;
|
||||
hal_uart_status_t uartstatus;
|
||||
|
||||
assert(serialHandle);
|
||||
|
||||
serialUartHandle = (serial_uart_state_t *)serialHandle;
|
||||
|
||||
uartstatus = HAL_UartExitLowpower(((hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
|
||||
assert(kStatus_HAL_UartSuccess == uartstatus);
|
||||
(void)uartstatus;
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_manager_type_t type =
|
||||
*(serial_manager_type_t *)(void *)((uint8_t *)serialHandle - SERIAL_MANAGER_BLOCK_OFFSET);
|
||||
if (type != kSerialManager_Blocking)
|
||||
{
|
||||
status = Serial_UartEnableReceiving(serialUartHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __SERIAL_PORT_UART_H__
|
||||
#define __SERIAL_PORT_UART_H__
|
||||
|
||||
#include "fsl_adapter_uart.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup serial_port_uart
|
||||
* @ingroup serialmanager
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief serial port uart handle size*/
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
#define SERIAL_PORT_UART_HANDLE_SIZE (76U + HAL_UART_HANDLE_SIZE)
|
||||
#define SERIAL_PORT_UART_BLOCK_HANDLE_SIZE (HAL_UART_BLOCK_HANDLE_SIZE)
|
||||
#else
|
||||
#define SERIAL_PORT_UART_HANDLE_SIZE (HAL_UART_HANDLE_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef SERIAL_USE_CONFIGURE_STRUCTURE
|
||||
#define SERIAL_USE_CONFIGURE_STRUCTURE (0U) /*!< Enable or disable the confgure structure pointer */
|
||||
#endif
|
||||
|
||||
/*! @brief serial port uart parity mode*/
|
||||
typedef enum _serial_port_uart_parity_mode
|
||||
{
|
||||
kSerialManager_UartParityDisabled = 0x0U, /*!< Parity disabled */
|
||||
kSerialManager_UartParityEven = 0x2U, /*!< Parity even enabled */
|
||||
kSerialManager_UartParityOdd = 0x3U, /*!< Parity odd enabled */
|
||||
} serial_port_uart_parity_mode_t;
|
||||
|
||||
/*! @brief serial port uart stop bit count*/
|
||||
typedef enum _serial_port_uart_stop_bit_count
|
||||
{
|
||||
kSerialManager_UartOneStopBit = 0U, /*!< One stop bit */
|
||||
kSerialManager_UartTwoStopBit = 1U, /*!< Two stop bits */
|
||||
} serial_port_uart_stop_bit_count_t;
|
||||
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
/*! @brief serial port uart block mode*/
|
||||
typedef enum _serial_port_uart_block_mode
|
||||
{
|
||||
kSerialManager_UartNonBlockMode = 0x0U, /*!< Uart NonBlock Mode */
|
||||
kSerialManager_UartBlockMode = 0x1U, /*!< Uart Block Mode */
|
||||
} serial_port_uart_block_mode_t;
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_MODE */
|
||||
|
||||
typedef struct _serial_port_uart_config
|
||||
{
|
||||
uint32_t clockRate; /*!< clock rate */
|
||||
uint32_t baudRate; /*!< baud rate */
|
||||
serial_port_uart_parity_mode_t parityMode; /*!< Parity mode, disabled (default), even, odd */
|
||||
serial_port_uart_stop_bit_count_t stopBitCount; /*!< Number of stop bits, 1 stop bit (default) or 2 stop bits */
|
||||
|
||||
uint8_t enableRx; /*!< Enable RX */
|
||||
uint8_t enableTx; /*!< Enable TX */
|
||||
uint8_t enableRxRTS; /*!< Enable RX RTS */
|
||||
uint8_t enableTxCTS; /*!< Enable TX CTS */
|
||||
uint8_t instance; /*!< Instance (0 - UART0, 1 - UART1, ...), detail information
|
||||
please refer to the SOC corresponding RM. */
|
||||
#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
|
||||
serial_port_uart_block_mode_t mode; /*!< serial port uart block mode */
|
||||
#endif /* SERIAL_MANAGER_NON_BLOCKING_MODE */
|
||||
#if (defined(HAL_UART_ADAPTER_FIFO) && (HAL_UART_ADAPTER_FIFO > 0u))
|
||||
uint8_t txFifoWatermark;
|
||||
uint8_t rxFifoWatermark;
|
||||
#endif
|
||||
} serial_port_uart_config_t;
|
||||
/*! @} */
|
||||
#endif /* __SERIAL_PORT_UART_H__ */
|
||||
+812
File diff suppressed because it is too large
Load Diff
+1086
File diff suppressed because it is too large
Load Diff
+30422
File diff suppressed because it is too large
Load Diff
+415
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Version: rev. 1.1, 2019-05-16
|
||||
** Build: b210318
|
||||
**
|
||||
** Abstract:
|
||||
** Chip specific module features.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2021 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2018-08-22)
|
||||
** Initial version based on v0.2UM
|
||||
** - rev. 1.1 (2019-05-16)
|
||||
** Initial A1 version based on v1.3UM
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
#ifndef _LPC55S69_cm33_core0_FEATURES_H_
|
||||
#define _LPC55S69_cm33_core0_FEATURES_H_
|
||||
|
||||
/* SOC module features */
|
||||
|
||||
/* @brief CASPER availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CASPER_COUNT (1)
|
||||
/* @brief CRC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CRC_COUNT (1)
|
||||
/* @brief CTIMER availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CTIMER_COUNT (5)
|
||||
/* @brief DMA availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_DMA_COUNT (2)
|
||||
/* @brief FLASH availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_FLASH_COUNT (1)
|
||||
/* @brief FLEXCOMM availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_FLEXCOMM_COUNT (9)
|
||||
/* @brief GINT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_GINT_COUNT (2)
|
||||
/* @brief GPIO availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_GPIO_COUNT (1)
|
||||
/* @brief SECGPIO availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SECGPIO_COUNT (1)
|
||||
/* @brief HASHCRYPT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_HASHCRYPT_COUNT (1)
|
||||
/* @brief I2C availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_I2C_COUNT (8)
|
||||
/* @brief I2S availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_I2S_COUNT (8)
|
||||
/* @brief INPUTMUX availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_INPUTMUX_COUNT (1)
|
||||
/* @brief IOCON availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_IOCON_COUNT (1)
|
||||
/* @brief LPADC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_LPADC_COUNT (1)
|
||||
/* @brief MAILBOX availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_MAILBOX_COUNT (1)
|
||||
/* @brief MRT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_MRT_COUNT (1)
|
||||
/* @brief OSTIMER availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_OSTIMER_COUNT (1)
|
||||
/* @brief PINT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_PINT_COUNT (1)
|
||||
/* @brief SECPINT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SECPINT_COUNT (1)
|
||||
/* @brief PMC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_PMC_COUNT (1)
|
||||
/* @brief POWERQUAD availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_POWERQUAD_COUNT (1)
|
||||
/* @brief PUF availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_PUF_COUNT (1)
|
||||
/* @brief LPC_RNG1 availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_LPC_RNG1_COUNT (1)
|
||||
/* @brief RTC availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_RTC_COUNT (1)
|
||||
/* @brief SCT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SCT_COUNT (1)
|
||||
/* @brief SDIF availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SDIF_COUNT (1)
|
||||
/* @brief SPI availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SPI_COUNT (9)
|
||||
/* @brief SYSCON availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SYSCON_COUNT (1)
|
||||
/* @brief SYSCTL1 availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_SYSCTL1_COUNT (1)
|
||||
/* @brief USART availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USART_COUNT (8)
|
||||
/* @brief USB availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USB_COUNT (1)
|
||||
/* @brief USBFSH availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USBFSH_COUNT (1)
|
||||
/* @brief USBHSD availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USBHSD_COUNT (1)
|
||||
/* @brief USBHSH availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USBHSH_COUNT (1)
|
||||
/* @brief USBPHY availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_USBPHY_COUNT (1)
|
||||
/* @brief UTICK availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_UTICK_COUNT (1)
|
||||
/* @brief WWDT availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_WWDT_COUNT (1)
|
||||
|
||||
/* LPADC module features */
|
||||
|
||||
/* @brief FIFO availability on the SoC. */
|
||||
#define FSL_FEATURE_LPADC_FIFO_COUNT (2)
|
||||
/* @brief Has subsequent trigger priority (bitfield CFG[TPRICTRL]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CFG_SUBSEQUENT_PRIORITY (1)
|
||||
/* @brief Has differential mode (bitfield CMDLn[DIFF]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDL_DIFF (0)
|
||||
/* @brief Has channel scale (bitfield CMDLn[CSCALE]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDL_CSCALE (0)
|
||||
/* @brief Has conversion type select (bitfield CMDLn[CTYPE]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDL_CTYPE (1)
|
||||
/* @brief Has conversion resolution select (bitfield CMDLn[MODE]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDL_MODE (1)
|
||||
/* @brief Has compare function enable (bitfield CMDHn[CMPEN]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDH_CMPEN (1)
|
||||
/* @brief Has Wait for trigger assertion before execution (bitfield CMDHn[WAIT_TRIG]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CMDH_WAIT_TRIG (1)
|
||||
/* @brief Has offset calibration (bitfield CTRL[CALOFS]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CTRL_CALOFS (1)
|
||||
/* @brief Has gain calibration (bitfield CTRL[CAL_REQ]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CTRL_CAL_REQ (1)
|
||||
/* @brief Has calibration average (bitfield CTRL[CAL_AVGS]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CTRL_CAL_AVGS (1)
|
||||
/* @brief Has internal clock (bitfield CFG[ADCKEN]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CFG_ADCKEN (0)
|
||||
/* @brief Enable support for low voltage reference on option 1 reference (bitfield CFG[VREF1RNG]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CFG_VREF1RNG (0)
|
||||
/* @brief Has calibration (bitfield CFG[CALOFS]). */
|
||||
#define FSL_FEATURE_LPADC_HAS_CFG_CALOFS (0)
|
||||
/* @brief Has offset trim (register OFSTRIM). */
|
||||
#define FSL_FEATURE_LPADC_HAS_OFSTRIM (1)
|
||||
/* @brief Has internal temperature sensor. */
|
||||
#define FSL_FEATURE_LPADC_HAS_INTERNAL_TEMP_SENSOR (1)
|
||||
/* @brief Temperature sensor parameter A (slope). */
|
||||
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_A (744.6f)
|
||||
/* @brief Temperature sensor parameter B (offset). */
|
||||
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_B (313.7f)
|
||||
/* @brief Temperature sensor parameter Alpha. */
|
||||
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_ALPHA (11.5f)
|
||||
/* @brief the buffer size of temperature sensor. */
|
||||
#define FSL_FEATURE_LPADC_TEMP_SENS_BUFFER_SIZE (4U)
|
||||
|
||||
/* CASPER module features */
|
||||
|
||||
/* @brief Base address of the CASPER dedicated RAM */
|
||||
#define FSL_FEATURE_CASPER_RAM_BASE_ADDRESS (0x04000000)
|
||||
/* @brief SW interleaving of the CASPER dedicated RAM */
|
||||
#define FSL_FEATURE_CASPER_RAM_IS_INTERLEAVED (1)
|
||||
/* @brief CASPER dedicated RAM offset */
|
||||
#define FSL_FEATURE_CASPER_RAM_OFFSET (0xE)
|
||||
|
||||
/* CTIMER module features */
|
||||
|
||||
/* No feature definitions */
|
||||
|
||||
/* DMA module features */
|
||||
|
||||
/* @brief Number of channels */
|
||||
#define FSL_FEATURE_DMA_NUMBER_OF_CHANNELS (23)
|
||||
/* @brief Align size of DMA descriptor */
|
||||
#define FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE (512)
|
||||
/* @brief DMA head link descriptor table align size */
|
||||
#define FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE (16U)
|
||||
|
||||
/* FLEXCOMM module features */
|
||||
|
||||
/* @brief FLEXCOMM0 USART INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_USART_INDEX (0)
|
||||
/* @brief FLEXCOMM0 SPI INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_SPI_INDEX (0)
|
||||
/* @brief FLEXCOMM0 I2C INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_I2C_INDEX (0)
|
||||
/* @brief FLEXCOMM0 I2S INDEX 0 */
|
||||
#define FSL_FEATURE_FLEXCOMM0_I2S_INDEX (0)
|
||||
/* @brief FLEXCOMM1 USART INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_USART_INDEX (1)
|
||||
/* @brief FLEXCOMM1 SPI INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_SPI_INDEX (1)
|
||||
/* @brief FLEXCOMM1 I2C INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_I2C_INDEX (1)
|
||||
/* @brief FLEXCOMM1 I2S INDEX 1 */
|
||||
#define FSL_FEATURE_FLEXCOMM1_I2S_INDEX (1)
|
||||
/* @brief FLEXCOMM2 USART INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_USART_INDEX (2)
|
||||
/* @brief FLEXCOMM2 SPI INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_SPI_INDEX (2)
|
||||
/* @brief FLEXCOMM2 I2C INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_I2C_INDEX (2)
|
||||
/* @brief FLEXCOMM2 I2S INDEX 2 */
|
||||
#define FSL_FEATURE_FLEXCOMM2_I2S_INDEX (2)
|
||||
/* @brief FLEXCOMM3 USART INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_USART_INDEX (3)
|
||||
/* @brief FLEXCOMM3 SPI INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_SPI_INDEX (3)
|
||||
/* @brief FLEXCOMM3 I2C INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_I2C_INDEX (3)
|
||||
/* @brief FLEXCOMM3 I2S INDEX 3 */
|
||||
#define FSL_FEATURE_FLEXCOMM3_I2S_INDEX (3)
|
||||
/* @brief FLEXCOMM4 USART INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_USART_INDEX (4)
|
||||
/* @brief FLEXCOMM4 SPI INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_SPI_INDEX (4)
|
||||
/* @brief FLEXCOMM4 I2C INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_I2C_INDEX (4)
|
||||
/* @brief FLEXCOMM4 I2S INDEX 4 */
|
||||
#define FSL_FEATURE_FLEXCOMM4_I2S_INDEX (4)
|
||||
/* @brief FLEXCOMM5 USART INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_USART_INDEX (5)
|
||||
/* @brief FLEXCOMM5 SPI INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_SPI_INDEX (5)
|
||||
/* @brief FLEXCOMM5 I2C INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_I2C_INDEX (5)
|
||||
/* @brief FLEXCOMM5 I2S INDEX 5 */
|
||||
#define FSL_FEATURE_FLEXCOMM5_I2S_INDEX (5)
|
||||
/* @brief FLEXCOMM6 USART INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_USART_INDEX (6)
|
||||
/* @brief FLEXCOMM6 SPI INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_SPI_INDEX (6)
|
||||
/* @brief FLEXCOMM6 I2C INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_I2C_INDEX (6)
|
||||
/* @brief FLEXCOMM6 I2S INDEX 6 */
|
||||
#define FSL_FEATURE_FLEXCOMM6_I2S_INDEX (6)
|
||||
/* @brief FLEXCOMM7 USART INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_USART_INDEX (7)
|
||||
/* @brief FLEXCOMM7 SPI INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_SPI_INDEX (7)
|
||||
/* @brief FLEXCOMM7 I2C INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_I2C_INDEX (7)
|
||||
/* @brief FLEXCOMM7 I2S INDEX 7 */
|
||||
#define FSL_FEATURE_FLEXCOMM7_I2S_INDEX (7)
|
||||
/* @brief FLEXCOMM8 SPI(HS_SPI) INDEX 8 */
|
||||
#define FSL_FEATURE_FLEXCOMM8_SPI_INDEX (8)
|
||||
/* @brief I2S has DMIC interconnection */
|
||||
#define FSL_FEATURE_FLEXCOMM_INSTANCE_I2S_HAS_DMIC_INTERCONNECTIONn(x) (0)
|
||||
|
||||
/* HASHCRYPT module features */
|
||||
|
||||
/* @brief the address of alias offset */
|
||||
#define FSL_FEATURE_HASHCRYPT_ALIAS_OFFSET (0x00000000)
|
||||
|
||||
/* I2S module features */
|
||||
|
||||
/* @brief I2S support dual channel transfer. */
|
||||
#define FSL_FEATURE_I2S_SUPPORT_SECONDARY_CHANNEL (0)
|
||||
/* @brief I2S has DMIC interconnection */
|
||||
#define FSL_FEATURE_FLEXCOMM_I2S_HAS_DMIC_INTERCONNECTION (0)
|
||||
|
||||
/* IOCON module features */
|
||||
|
||||
/* @brief Func bit field width */
|
||||
#define FSL_FEATURE_IOCON_FUNC_FIELD_WIDTH (4)
|
||||
|
||||
/* MAILBOX module features */
|
||||
|
||||
/* @brief Mailbox side for current core */
|
||||
#define FSL_FEATURE_MAILBOX_SIDE_A (1)
|
||||
|
||||
/* MRT module features */
|
||||
|
||||
/* @brief number of channels. */
|
||||
#define FSL_FEATURE_MRT_NUMBER_OF_CHANNELS (4)
|
||||
|
||||
/* PINT module features */
|
||||
|
||||
/* @brief Number of connected outputs */
|
||||
#define FSL_FEATURE_PINT_NUMBER_OF_CONNECTED_OUTPUTS (8)
|
||||
|
||||
/* PLU module features */
|
||||
|
||||
/* @brief Has WAKEINT_CTRL register. */
|
||||
#define FSL_FEATURE_PLU_HAS_WAKEINT_CTRL_REG (1)
|
||||
|
||||
/* PMC module features */
|
||||
|
||||
/* @brief UTICK does not support PD configure. */
|
||||
#define FSL_FEATURE_UTICK_HAS_NO_PDCFG (1)
|
||||
/* @brief WDT OSC does not support PD configure. */
|
||||
#define FSL_FEATURE_WWDT_HAS_NO_PDCFG (1)
|
||||
|
||||
/* POWERLIB module features */
|
||||
|
||||
/* @brief Powerlib API is different with other LPC series devices. */
|
||||
#define FSL_FEATURE_POWERLIB_EXTEND (1)
|
||||
|
||||
/* POWERQUAD module features */
|
||||
|
||||
/* @brief Sine and Cossine fix errata */
|
||||
#define FSL_FEATURE_POWERQUAD_SIN_COS_FIX_ERRATA (1)
|
||||
|
||||
/* PUF module features */
|
||||
|
||||
/* @brief Number of PUF key slots available on device. */
|
||||
#define FSL_FEATURE_PUF_HAS_KEYSLOTS (4)
|
||||
/* @brief the shift status value */
|
||||
#define FSL_FEATURE_PUF_HAS_SHIFT_STATUS (1)
|
||||
|
||||
/* RTC module features */
|
||||
|
||||
/* No feature definitions */
|
||||
|
||||
/* SCT module features */
|
||||
|
||||
/* @brief Number of events */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_EVENTS (16)
|
||||
/* @brief Number of states */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_STATES (32)
|
||||
/* @brief Number of match capture */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_MATCH_CAPTURE (16)
|
||||
/* @brief Number of outputs */
|
||||
#define FSL_FEATURE_SCT_NUMBER_OF_OUTPUTS (10)
|
||||
|
||||
/* SDIF module features */
|
||||
|
||||
/* @brief FIFO depth, every location is a WORD */
|
||||
#define FSL_FEATURE_SDIF_FIFO_DEPTH_64_32BITS (64)
|
||||
/* @brief Max DMA buffer size */
|
||||
#define FSL_FEATURE_SDIF_INTERNAL_DMA_MAX_BUFFER_SIZE (4096)
|
||||
/* @brief Max source clock in HZ */
|
||||
#define FSL_FEATURE_SDIF_MAX_SOURCE_CLOCK (52000000)
|
||||
/* @brief support 2 cards */
|
||||
#define FSL_FEATURE_SDIF_ONE_INSTANCE_SUPPORT_TWO_CARD (1)
|
||||
|
||||
/* SECPINT module features */
|
||||
|
||||
/* @brief Number of connected outputs */
|
||||
#define FSL_FEATURE_SECPINT_NUMBER_OF_CONNECTED_OUTPUTS (2)
|
||||
|
||||
/* SYSCON module features */
|
||||
|
||||
/* @brief Flash page size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES (512)
|
||||
/* @brief Flash sector size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_SECTOR_SIZE_BYTES (32768)
|
||||
/* @brief Flash size in bytes */
|
||||
#define FSL_FEATURE_SYSCON_FLASH_SIZE_BYTES (622592)
|
||||
/* @brief Has Power Down mode */
|
||||
#define FSL_FEATURE_SYSCON_HAS_POWERDOWN_MODE (1)
|
||||
/* @brief CCM_ANALOG availability on the SoC. */
|
||||
#define FSL_FEATURE_SOC_CCM_ANALOG_COUNT (1)
|
||||
/* @brief Starter register discontinuous. */
|
||||
#define FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS (1)
|
||||
|
||||
/* SYSCTL1 module features */
|
||||
|
||||
/* No feature definitions */
|
||||
|
||||
/* USB module features */
|
||||
|
||||
/* @brief Size of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USB_USB_RAM (0x00004000)
|
||||
/* @brief Base address of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USB_USB_RAM_BASE_ADDRESS (0x40100000)
|
||||
/* @brief USB version */
|
||||
#define FSL_FEATURE_USB_VERSION (200)
|
||||
/* @brief Number of the endpoint in USB FS */
|
||||
#define FSL_FEATURE_USB_EP_NUM (5)
|
||||
|
||||
/* USBFSH module features */
|
||||
|
||||
/* @brief Size of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBFSH_USB_RAM (0x00004000)
|
||||
/* @brief Base address of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBFSH_USB_RAM_BASE_ADDRESS (0x40100000)
|
||||
/* @brief USBFSH version */
|
||||
#define FSL_FEATURE_USBFSH_VERSION (200)
|
||||
|
||||
/* USBHSD module features */
|
||||
|
||||
/* @brief Size of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBHSD_USB_RAM (0x00004000)
|
||||
/* @brief Base address of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBHSD_USB_RAM_BASE_ADDRESS (0x40100000)
|
||||
/* @brief USBHSD version */
|
||||
#define FSL_FEATURE_USBHSD_VERSION (300)
|
||||
/* @brief Number of the endpoint in USB HS */
|
||||
#define FSL_FEATURE_USBHSD_EP_NUM (6)
|
||||
|
||||
/* USBHSH module features */
|
||||
|
||||
/* @brief Size of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBHSH_USB_RAM (0x00004000)
|
||||
/* @brief Base address of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBHSH_USB_RAM_BASE_ADDRESS (0x40100000)
|
||||
/* @brief USBHSH version */
|
||||
#define FSL_FEATURE_USBHSH_VERSION (300)
|
||||
|
||||
/* USBPHY module features */
|
||||
|
||||
/* @brief Size of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBPHY_USB_RAM (0x00004000)
|
||||
/* @brief Base address of the USB dedicated RAM */
|
||||
#define FSL_FEATURE_USBPHY_USB_RAM_BASE_ADDRESS (0x40100000)
|
||||
/* @brief USBHSD version */
|
||||
#define FSL_FEATURE_USBPHY_VERSION (300)
|
||||
/* @brief Number of the endpoint in USB HS */
|
||||
#define FSL_FEATURE_USBPHY_EP_NUM (6)
|
||||
|
||||
/* WWDT module features */
|
||||
|
||||
/* @brief Has no RESET register. */
|
||||
#define FSL_FEATURE_WWDT_HAS_NO_RESET (1)
|
||||
/* @brief WWDT does not support oscillator lock. */
|
||||
#define FSL_FEATURE_WWDT_HAS_NO_OSCILLATOR_LOCK (1)
|
||||
|
||||
#endif /* _LPC55S69_cm33_core0_FEATURES_H_ */
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2014-2016 Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FSL_DEVICE_REGISTERS_H__
|
||||
#define __FSL_DEVICE_REGISTERS_H__
|
||||
|
||||
/*
|
||||
* Include the cpu specific register header files.
|
||||
*
|
||||
* The CPU macro should be declared in the project or makefile.
|
||||
*/
|
||||
#if (defined(CPU_LPC55S69JBD100_cm33_core0) || defined(CPU_LPC55S69JBD64_cm33_core0) || \
|
||||
defined(CPU_LPC55S69JEV98_cm33_core0))
|
||||
|
||||
#define LPC55S69_cm33_core0_SERIES
|
||||
|
||||
/* CMSIS-style register definitions */
|
||||
#include "LPC55S69_cm33_core0.h"
|
||||
/* CPU specific feature definitions */
|
||||
#include "LPC55S69_cm33_core0_features.h"
|
||||
|
||||
#elif (defined(CPU_LPC55S69JBD100_cm33_core1) || defined(CPU_LPC55S69JBD64_cm33_core1) || \
|
||||
defined(CPU_LPC55S69JEV98_cm33_core1))
|
||||
|
||||
#define LPC55S69_cm33_core1_SERIES
|
||||
|
||||
/* CMSIS-style register definitions */
|
||||
#include "LPC55S69_cm33_core1.h"
|
||||
/* CPU specific feature definitions */
|
||||
#include "LPC55S69_cm33_core1_features.h"
|
||||
|
||||
#else
|
||||
#error "No valid CPU defined!"
|
||||
#endif
|
||||
|
||||
#endif /* __FSL_DEVICE_REGISTERS_H__ */
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF
|
||||
******************************************************************************/
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: LPC55S69JBD100_cm33_core0
|
||||
** LPC55S69JBD64_cm33_core0
|
||||
** LPC55S69JEV98_cm33_core0
|
||||
**
|
||||
** Compilers: GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** Keil ARM C/C++ Compiler
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: LPC55S6x/LPC55S2x/LPC552x User manual(UM11126) Rev.1.3 16 May 2019
|
||||
** Version: rev. 1.1, 2019-05-16
|
||||
** Build: b200418
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2020 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2018-08-22)
|
||||
** Initial version based on v0.2UM
|
||||
** - rev. 1.1 (2019-05-16)
|
||||
** Initial A1 version based on v1.3UM
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file LPC55S69_cm33_core0
|
||||
* @version 1.1
|
||||
* @date 2019-05-16
|
||||
* @brief Device specific configuration file for LPC55S69_cm33_core0
|
||||
* (implementation file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/* PLL0 SSCG control1 */
|
||||
#define PLL_SSCG_MD_FRACT_P 0U
|
||||
#define PLL_SSCG_MD_INT_P 25U
|
||||
#define PLL_SSCG_MD_FRACT_M (0x1FFFFFFUL << PLL_SSCG_MD_FRACT_P)
|
||||
#define PLL_SSCG_MD_INT_M ((uint64_t)0xFFUL << PLL_SSCG_MD_INT_P)
|
||||
|
||||
/* Get predivider (N) from PLL0 NDEC setting */
|
||||
static uint32_t findPll0PreDiv(void)
|
||||
{
|
||||
uint32_t preDiv = 1UL;
|
||||
|
||||
/* Direct input is not used? */
|
||||
if ((SYSCON->PLL0CTRL & SYSCON_PLL0CTRL_BYPASSPREDIV_MASK) == 0UL)
|
||||
{
|
||||
preDiv = SYSCON->PLL0NDEC & SYSCON_PLL0NDEC_NDIV_MASK;
|
||||
if (preDiv == 0UL)
|
||||
{
|
||||
preDiv = 1UL;
|
||||
}
|
||||
}
|
||||
return preDiv;
|
||||
}
|
||||
|
||||
/* Get postdivider (P) from PLL0 PDEC setting */
|
||||
static uint32_t findPll0PostDiv(void)
|
||||
{
|
||||
uint32_t postDiv = 1;
|
||||
|
||||
if ((SYSCON->PLL0CTRL & SYSCON_PLL0CTRL_BYPASSPOSTDIV_MASK) == 0UL)
|
||||
{
|
||||
if ((SYSCON->PLL0CTRL & SYSCON_PLL0CTRL_BYPASSPOSTDIV2_MASK) != 0UL)
|
||||
{
|
||||
postDiv = SYSCON->PLL0PDEC & SYSCON_PLL0PDEC_PDIV_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
postDiv = 2UL * (SYSCON->PLL0PDEC & SYSCON_PLL0PDEC_PDIV_MASK);
|
||||
}
|
||||
if (postDiv == 0UL)
|
||||
{
|
||||
postDiv = 2UL;
|
||||
}
|
||||
}
|
||||
return postDiv;
|
||||
}
|
||||
|
||||
/* Get multiplier (M) from PLL0 SSCG and SEL_EXT settings */
|
||||
static float findPll0MMult(void)
|
||||
{
|
||||
float mMult = 1.0F;
|
||||
float mMult_fract;
|
||||
uint32_t mMult_int;
|
||||
|
||||
if ((SYSCON->PLL0SSCG1 & SYSCON_PLL0SSCG1_SEL_EXT_MASK) != 0UL)
|
||||
{
|
||||
mMult = (float)(uint32_t)((SYSCON->PLL0SSCG1 & SYSCON_PLL0SSCG1_MDIV_EXT_MASK) >> SYSCON_PLL0SSCG1_MDIV_EXT_SHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMult_int = ((SYSCON->PLL0SSCG1 & SYSCON_PLL0SSCG1_MD_MBS_MASK) << 7U);
|
||||
mMult_int = mMult_int | ((SYSCON->PLL0SSCG0) >> PLL_SSCG_MD_INT_P);
|
||||
mMult_fract = ((float)(uint32_t)((SYSCON->PLL0SSCG0) & PLL_SSCG_MD_FRACT_M) /
|
||||
(float)(uint32_t)(1UL << PLL_SSCG_MD_INT_P));
|
||||
mMult = (float)mMult_int + mMult_fract;
|
||||
}
|
||||
if (mMult == 0.0F)
|
||||
{
|
||||
mMult = 1.0F;
|
||||
}
|
||||
return mMult;
|
||||
}
|
||||
|
||||
/* Get predivider (N) from PLL1 NDEC setting */
|
||||
static uint32_t findPll1PreDiv(void)
|
||||
{
|
||||
uint32_t preDiv = 1UL;
|
||||
|
||||
/* Direct input is not used? */
|
||||
if ((SYSCON->PLL1CTRL & SYSCON_PLL1CTRL_BYPASSPREDIV_MASK) == 0UL)
|
||||
{
|
||||
preDiv = SYSCON->PLL1NDEC & SYSCON_PLL1NDEC_NDIV_MASK;
|
||||
if (preDiv == 0UL)
|
||||
{
|
||||
preDiv = 1UL;
|
||||
}
|
||||
}
|
||||
return preDiv;
|
||||
}
|
||||
|
||||
/* Get postdivider (P) from PLL1 PDEC setting */
|
||||
static uint32_t findPll1PostDiv(void)
|
||||
{
|
||||
uint32_t postDiv = 1UL;
|
||||
|
||||
if ((SYSCON->PLL1CTRL & SYSCON_PLL1CTRL_BYPASSPOSTDIV_MASK) == 0UL)
|
||||
{
|
||||
if ((SYSCON->PLL1CTRL & SYSCON_PLL1CTRL_BYPASSPOSTDIV2_MASK) != 0UL)
|
||||
{
|
||||
postDiv = SYSCON->PLL1PDEC & SYSCON_PLL1PDEC_PDIV_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
postDiv = 2UL * (SYSCON->PLL1PDEC & SYSCON_PLL1PDEC_PDIV_MASK);
|
||||
}
|
||||
if (postDiv == 0UL)
|
||||
{
|
||||
postDiv = 2UL;
|
||||
}
|
||||
}
|
||||
return postDiv;
|
||||
}
|
||||
|
||||
/* Get multiplier (M) from PLL1 MDEC settings */
|
||||
static uint32_t findPll1MMult(void)
|
||||
{
|
||||
uint32_t mMult = 1UL;
|
||||
|
||||
mMult = SYSCON->PLL1MDEC & SYSCON_PLL1MDEC_MDIV_MASK;
|
||||
|
||||
if (mMult == 0UL)
|
||||
{
|
||||
mMult = 1UL;
|
||||
}
|
||||
return mMult;
|
||||
}
|
||||
|
||||
/* Get FRO 12M Clk */
|
||||
/*! brief Return Frequency of FRO 12MHz
|
||||
* return Frequency of FRO 12MHz
|
||||
*/
|
||||
static uint32_t GetFro12MFreq(void)
|
||||
{
|
||||
return ((ANACTRL->FRO192M_CTRL & ANACTRL_FRO192M_CTRL_ENA_12MHZCLK_MASK) != 0UL) ? 12000000U : 0U;
|
||||
}
|
||||
|
||||
/* Get FRO 1M Clk */
|
||||
/*! brief Return Frequency of FRO 1MHz
|
||||
* return Frequency of FRO 1MHz
|
||||
*/
|
||||
static uint32_t GetFro1MFreq(void)
|
||||
{
|
||||
return ((SYSCON->CLOCK_CTRL & SYSCON_CLOCK_CTRL_FRO1MHZ_CLK_ENA_MASK) != 0UL) ? 1000000U : 0U;
|
||||
}
|
||||
|
||||
/* Get EXT OSC Clk */
|
||||
/*! brief Return Frequency of External Clock
|
||||
* return Frequency of External Clock. If no external clock is used returns 0.
|
||||
*/
|
||||
static uint32_t GetExtClkFreq(void)
|
||||
{
|
||||
return ((ANACTRL->XO32M_CTRL & ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK) != 0UL) ? CLK_CLK_IN : 0U;
|
||||
}
|
||||
|
||||
/* Get HF FRO Clk */
|
||||
/*! brief Return Frequency of High-Freq output of FRO
|
||||
* return Frequency of High-Freq output of FRO
|
||||
*/
|
||||
static uint32_t GetFroHfFreq(void)
|
||||
{
|
||||
return ((ANACTRL->FRO192M_CTRL & ANACTRL_FRO192M_CTRL_ENA_96MHZCLK_MASK) != 0UL) ? 96000000U : 0U;
|
||||
}
|
||||
|
||||
/* Get RTC OSC Clk */
|
||||
/*! brief Return Frequency of 32kHz osc
|
||||
* return Frequency of 32kHz osc
|
||||
*/
|
||||
static uint32_t GetOsc32KFreq(void)
|
||||
{
|
||||
return ((0UL == (PMC->PDRUNCFG0 & PMC_PDRUNCFG0_PDEN_FRO32K_MASK)) && (0UL == (PMC->RTCOSC32K & PMC_RTCOSC32K_SEL_MASK))) ?
|
||||
CLK_RTC_32K_CLK :
|
||||
((0UL == (PMC->PDRUNCFG0 & PMC_PDRUNCFG0_PDEN_XTAL32K_MASK)) && ((PMC->RTCOSC32K & PMC_RTCOSC32K_SEL_MASK) != 0UL)) ?
|
||||
CLK_RTC_32K_CLK :
|
||||
0U;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Core clock
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
__attribute__((weak)) void SystemInit (void) {
|
||||
#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))
|
||||
SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2)); /* set CP10, CP11 Full Access in Secure mode */
|
||||
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
||||
SCB_NS->CPACR |= ((3UL << 10*2) | (3UL << 11*2)); /* set CP10, CP11 Full Access in Non-secure mode */
|
||||
#endif /* (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
|
||||
#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */
|
||||
|
||||
SCB->CPACR |= ((3UL << 0*2) | (3UL << 1*2)); /* set CP0, CP1 Full Access in Secure mode (enable PowerQuad) */
|
||||
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
||||
SCB_NS->CPACR |= ((3UL << 0*2) | (3UL << 1*2)); /* set CP0, CP1 Full Access in Normal mode (enable PowerQuad) */
|
||||
#endif /* (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
|
||||
|
||||
SCB->NSACR |= ((3UL << 0) | (3UL << 10)); /* enable CP0, CP1, CP10, CP11 Non-secure Access */
|
||||
|
||||
#if defined(__MCUXPRESSO)
|
||||
extern void(*const g_pfnVectors[]) (void);
|
||||
SCB->VTOR = (uint32_t) &g_pfnVectors;
|
||||
#else
|
||||
extern void *__Vectors;
|
||||
SCB->VTOR = (uint32_t) &__Vectors;
|
||||
#endif
|
||||
SYSCON->TRACECLKDIV = 0;
|
||||
/* Optionally enable RAM banks that may be off by default at reset */
|
||||
#if !defined(DONT_ENABLE_DISABLED_RAMBANKS)
|
||||
SYSCON->AHBCLKCTRLSET[0] = SYSCON_AHBCLKCTRL0_SRAM_CTRL1_MASK | SYSCON_AHBCLKCTRL0_SRAM_CTRL2_MASK
|
||||
| SYSCON_AHBCLKCTRL0_SRAM_CTRL3_MASK | SYSCON_AHBCLKCTRL0_SRAM_CTRL4_MASK;
|
||||
#endif
|
||||
SystemInitHook();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemCoreClockUpdate()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemCoreClockUpdate (void) {
|
||||
uint32_t clkRate = 0;
|
||||
uint32_t prediv, postdiv;
|
||||
uint64_t workRate;
|
||||
uint64_t workRate1;
|
||||
|
||||
switch (SYSCON->MAINCLKSELB & SYSCON_MAINCLKSELB_SEL_MASK)
|
||||
{
|
||||
case 0x00: /* MAINCLKSELA clock (main_clk_a)*/
|
||||
switch (SYSCON->MAINCLKSELA & SYSCON_MAINCLKSELA_SEL_MASK)
|
||||
{
|
||||
case 0x00: /* FRO 12 MHz (fro_12m) */
|
||||
clkRate = GetFro12MFreq();
|
||||
break;
|
||||
case 0x01: /* CLKIN (clk_in) */
|
||||
clkRate = GetExtClkFreq();
|
||||
break;
|
||||
case 0x02: /* Fro 1MHz (fro_1m) */
|
||||
clkRate = GetFro1MFreq();
|
||||
break;
|
||||
default: /* = 0x03 = FRO 96 MHz (fro_hf) */
|
||||
clkRate = GetFroHfFreq();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x01: /* PLL0 clock (pll0_clk)*/
|
||||
switch (SYSCON->PLL0CLKSEL & SYSCON_PLL0CLKSEL_SEL_MASK)
|
||||
{
|
||||
case 0x00: /* FRO 12 MHz (fro_12m) */
|
||||
clkRate = GetFro12MFreq();
|
||||
break;
|
||||
case 0x01: /* CLKIN (clk_in) */
|
||||
clkRate = GetExtClkFreq();
|
||||
break;
|
||||
case 0x02: /* Fro 1MHz (fro_1m) */
|
||||
clkRate = GetFro1MFreq();
|
||||
break;
|
||||
case 0x03: /* RTC oscillator 32 kHz output (32k_clk) */
|
||||
clkRate = GetOsc32KFreq();
|
||||
break;
|
||||
default:
|
||||
clkRate = 0UL;
|
||||
break;
|
||||
}
|
||||
if (((SYSCON->PLL0CTRL & SYSCON_PLL0CTRL_BYPASSPLL_MASK) == 0UL) && ((SYSCON->PLL0CTRL & SYSCON_PLL0CTRL_CLKEN_MASK) != 0UL) && ((PMC->PDRUNCFG0 & PMC_PDRUNCFG0_PDEN_PLL0_MASK) == 0UL) && ((PMC->PDRUNCFG0 & PMC_PDRUNCFG0_PDEN_PLL0_SSCG_MASK) == 0UL))
|
||||
{
|
||||
prediv = findPll0PreDiv();
|
||||
postdiv = findPll0PostDiv();
|
||||
/* Adjust input clock */
|
||||
clkRate = clkRate / prediv;
|
||||
/* MDEC used for rate */
|
||||
workRate = (uint64_t)clkRate * (uint64_t)findPll0MMult();
|
||||
clkRate = (uint32_t)(workRate / ((uint64_t)postdiv));
|
||||
}
|
||||
break;
|
||||
case 0x02: /* PLL1 clock (pll1_clk)*/
|
||||
switch (SYSCON->PLL1CLKSEL & SYSCON_PLL1CLKSEL_SEL_MASK)
|
||||
{
|
||||
case 0x00: /* FRO 12 MHz (fro_12m) */
|
||||
clkRate = GetFro12MFreq();
|
||||
break;
|
||||
case 0x01: /* CLKIN (clk_in) */
|
||||
clkRate = GetExtClkFreq();
|
||||
break;
|
||||
case 0x02: /* Fro 1MHz (fro_1m) */
|
||||
clkRate = GetFro1MFreq();
|
||||
break;
|
||||
case 0x03: /* RTC oscillator 32 kHz output (32k_clk) */
|
||||
clkRate = GetOsc32KFreq();
|
||||
break;
|
||||
default:
|
||||
clkRate = 0UL;
|
||||
break;
|
||||
}
|
||||
if (((SYSCON->PLL1CTRL & SYSCON_PLL1CTRL_BYPASSPLL_MASK) == 0UL) && ((SYSCON->PLL1CTRL & SYSCON_PLL1CTRL_CLKEN_MASK) != 0UL) && ((PMC->PDRUNCFG0 & PMC_PDRUNCFG0_PDEN_PLL1_MASK) == 0UL))
|
||||
{
|
||||
/* PLL is not in bypass mode, get pre-divider, post-divider, and M divider */
|
||||
prediv = findPll1PreDiv();
|
||||
postdiv = findPll1PostDiv();
|
||||
/* Adjust input clock */
|
||||
clkRate = clkRate / prediv;
|
||||
|
||||
/* MDEC used for rate */
|
||||
workRate1 = (uint64_t)clkRate * (uint64_t)findPll1MMult();
|
||||
clkRate = (uint32_t)(workRate1 / ((uint64_t)postdiv));
|
||||
}
|
||||
break;
|
||||
case 0x03: /* RTC oscillator 32 kHz output (32k_clk) */
|
||||
clkRate = GetOsc32KFreq();
|
||||
break;
|
||||
default:
|
||||
clkRate = 0UL;
|
||||
break;
|
||||
}
|
||||
SystemCoreClock = clkRate / ((SYSCON->AHBCLKDIV & 0xFFUL) + 1UL);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInitHook()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
__attribute__ ((weak)) void SystemInitHook (void) {
|
||||
/* Void implementation of the weak function. */
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: LPC55S69JBD100_cm33_core0
|
||||
** LPC55S69JBD64_cm33_core0
|
||||
** LPC55S69JEV98_cm33_core0
|
||||
**
|
||||
** Compilers: GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** Keil ARM C/C++ Compiler
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: LPC55S6x/LPC55S2x/LPC552x User manual(UM11126) Rev.1.3 16 May 2019
|
||||
** Version: rev. 1.1, 2019-05-16
|
||||
** Build: b200418
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2020 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2018-08-22)
|
||||
** Initial version based on v0.2UM
|
||||
** - rev. 1.1 (2019-05-16)
|
||||
** Initial A1 version based on v1.3UM
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file LPC55S69_cm33_core0
|
||||
* @version 1.1
|
||||
* @date 2019-05-16
|
||||
* @brief Device specific configuration file for LPC55S69_cm33_core0 (header
|
||||
* file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#ifndef _SYSTEM_LPC55S69_cm33_core0_H_
|
||||
#define _SYSTEM_LPC55S69_cm33_core0_H_ /**< Symbol preventing repeated inclusion */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEFAULT_SYSTEM_CLOCK 12000000u /* Default System clock value */
|
||||
#define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz output (32k_clk */
|
||||
#define CLK_FRO_12MHZ 12000000u /* FRO 12 MHz (fro_12m) */
|
||||
#define CLK_FRO_48MHZ 48000000u /* FRO 48 MHz (fro_48m) */
|
||||
#define CLK_FRO_96MHZ 96000000u /* FRO 96 MHz (fro_96m) */
|
||||
#define CLK_CLK_IN 16000000u /* Default CLK_IN pin clock */
|
||||
|
||||
|
||||
/**
|
||||
* @brief System clock frequency (core clock)
|
||||
*
|
||||
* The system clock frequency supplied to the SysTick timer and the processor
|
||||
* core clock. This variable can be used by the user application to setup the
|
||||
* SysTick timer or configure other parameters. It may also be used by debugger to
|
||||
* query the frequency of the debug timer or configure the trace clock speed
|
||||
* SystemCoreClock is initialized with a correct predefined value.
|
||||
*/
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
*
|
||||
* Typically this function configures the oscillator (PLL) that is part of the
|
||||
* microcontroller device. For systems with variable clock speed it also updates
|
||||
* the variable SystemCoreClock. SystemInit is called from startup_device file.
|
||||
*/
|
||||
void SystemInit (void);
|
||||
|
||||
/**
|
||||
* @brief Updates the SystemCoreClock variable.
|
||||
*
|
||||
* It must be called whenever the core clock is changed during program
|
||||
* execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
|
||||
* the current core clock.
|
||||
*/
|
||||
void SystemCoreClockUpdate (void);
|
||||
|
||||
/**
|
||||
* @brief SystemInit function hook.
|
||||
*
|
||||
* This weak function allows to call specific initialization code during the
|
||||
* SystemInit() execution.This can be used when an application specific code needs
|
||||
* to be called as close to the reset entry as possible (for example the Multicore
|
||||
* Manager MCMGR_EarlyInit() function call).
|
||||
* NOTE: No global r/w variables can be used in this hook function because the
|
||||
* initialization of these variables happens after this function.
|
||||
*/
|
||||
void SystemInitHook (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYSTEM_LPC55S69_cm33_core0_H_ */
|
||||
+2095
File diff suppressed because it is too large
Load Diff
+1501
File diff suppressed because it is too large
Load Diff
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2021 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
#define SDK_MEM_MAGIC_NUMBER 12345U
|
||||
|
||||
typedef struct _mem_align_control_block
|
||||
{
|
||||
uint16_t identifier; /*!< Identifier for the memory control block. */
|
||||
uint16_t offset; /*!< offset from aligned address to real address */
|
||||
} mem_align_cb_t;
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.common"
|
||||
#endif
|
||||
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes)
|
||||
{
|
||||
mem_align_cb_t *p_cb = NULL;
|
||||
uint32_t alignedsize;
|
||||
|
||||
/* Check overflow. */
|
||||
alignedsize = SDK_SIZEALIGN(size, alignbytes);
|
||||
if (alignedsize < size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (alignedsize > SIZE_MAX - alignbytes - sizeof(mem_align_cb_t))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
alignedsize += alignbytes + sizeof(mem_align_cb_t);
|
||||
|
||||
union
|
||||
{
|
||||
void *pointer_value;
|
||||
uint32_t unsigned_value;
|
||||
} p_align_addr, p_addr;
|
||||
|
||||
p_addr.pointer_value = malloc(alignedsize);
|
||||
|
||||
if (p_addr.pointer_value == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p_align_addr.unsigned_value = SDK_SIZEALIGN(p_addr.unsigned_value + sizeof(mem_align_cb_t), alignbytes);
|
||||
|
||||
p_cb = (mem_align_cb_t *)(p_align_addr.unsigned_value - 4U);
|
||||
p_cb->identifier = SDK_MEM_MAGIC_NUMBER;
|
||||
p_cb->offset = (uint16_t)(p_align_addr.unsigned_value - p_addr.unsigned_value);
|
||||
|
||||
return p_align_addr.pointer_value;
|
||||
}
|
||||
|
||||
void SDK_Free(void *ptr)
|
||||
{
|
||||
union
|
||||
{
|
||||
void *pointer_value;
|
||||
uint32_t unsigned_value;
|
||||
} p_free;
|
||||
p_free.pointer_value = ptr;
|
||||
mem_align_cb_t *p_cb = (mem_align_cb_t *)(p_free.unsigned_value - 4U);
|
||||
|
||||
if (p_cb->identifier != SDK_MEM_MAGIC_NUMBER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p_free.unsigned_value = p_free.unsigned_value - p_cb->offset;
|
||||
|
||||
free(p_free.pointer_value);
|
||||
}
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2021 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_COMMON_H_
|
||||
#define _FSL_COMMON_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(__ICCARM__) || (defined(__CC_ARM) || defined(__ARMCC_VERSION)) || defined(__GNUC__)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup ksdk_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Configurations
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Macro to use the default weak IRQ handler in drivers. */
|
||||
#ifndef FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ
|
||||
#define FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ 1
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Construct a status code value from a group and code number. */
|
||||
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))
|
||||
|
||||
/*! @brief Construct the version number for drivers. */
|
||||
#define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief common driver version. */
|
||||
#define FSL_COMMON_DRIVER_VERSION (MAKE_VERSION(2, 3, 0))
|
||||
/*@}*/
|
||||
|
||||
/* Debug console type definition. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U /*!< No debug console. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U /*!< Debug console based on UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U /*!< Debug console based on LPUART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U /*!< Debug console based on LPSCI. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U /*!< Debug console based on USBCDC. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U /*!< Debug console based on FLEXCOMM. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U /*!< Debug console based on i.MX UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_VUSART 7U /*!< Debug console based on LPC_VUSART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART 8U /*!< Debug console based on LPC_USART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_SWO 9U /*!< Debug console based on SWO. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_QSCI 10U /*!< Debug console based on QSCI. */
|
||||
|
||||
/*! @brief Status group numbers. */
|
||||
enum _status_groups
|
||||
{
|
||||
kStatusGroup_Generic = 0, /*!< Group number for generic status codes. */
|
||||
kStatusGroup_FLASH = 1, /*!< Group number for FLASH status codes. */
|
||||
kStatusGroup_LPSPI = 4, /*!< Group number for LPSPI status codes. */
|
||||
kStatusGroup_FLEXIO_SPI = 5, /*!< Group number for FLEXIO SPI status codes. */
|
||||
kStatusGroup_DSPI = 6, /*!< Group number for DSPI status codes. */
|
||||
kStatusGroup_FLEXIO_UART = 7, /*!< Group number for FLEXIO UART status codes. */
|
||||
kStatusGroup_FLEXIO_I2C = 8, /*!< Group number for FLEXIO I2C status codes. */
|
||||
kStatusGroup_LPI2C = 9, /*!< Group number for LPI2C status codes. */
|
||||
kStatusGroup_UART = 10, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_I2C = 11, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_LPSCI = 12, /*!< Group number for LPSCI status codes. */
|
||||
kStatusGroup_LPUART = 13, /*!< Group number for LPUART status codes. */
|
||||
kStatusGroup_SPI = 14, /*!< Group number for SPI status code.*/
|
||||
kStatusGroup_XRDC = 15, /*!< Group number for XRDC status code.*/
|
||||
kStatusGroup_SEMA42 = 16, /*!< Group number for SEMA42 status code.*/
|
||||
kStatusGroup_SDHC = 17, /*!< Group number for SDHC status code */
|
||||
kStatusGroup_SDMMC = 18, /*!< Group number for SDMMC status code */
|
||||
kStatusGroup_SAI = 19, /*!< Group number for SAI status code */
|
||||
kStatusGroup_MCG = 20, /*!< Group number for MCG status codes. */
|
||||
kStatusGroup_SCG = 21, /*!< Group number for SCG status codes. */
|
||||
kStatusGroup_SDSPI = 22, /*!< Group number for SDSPI status codes. */
|
||||
kStatusGroup_FLEXIO_I2S = 23, /*!< Group number for FLEXIO I2S status codes */
|
||||
kStatusGroup_FLEXIO_MCULCD = 24, /*!< Group number for FLEXIO LCD status codes */
|
||||
kStatusGroup_FLASHIAP = 25, /*!< Group number for FLASHIAP status codes */
|
||||
kStatusGroup_FLEXCOMM_I2C = 26, /*!< Group number for FLEXCOMM I2C status codes */
|
||||
kStatusGroup_I2S = 27, /*!< Group number for I2S status codes */
|
||||
kStatusGroup_IUART = 28, /*!< Group number for IUART status codes */
|
||||
kStatusGroup_CSI = 29, /*!< Group number for CSI status codes */
|
||||
kStatusGroup_MIPI_DSI = 30, /*!< Group number for MIPI DSI status codes */
|
||||
kStatusGroup_SDRAMC = 35, /*!< Group number for SDRAMC status codes. */
|
||||
kStatusGroup_POWER = 39, /*!< Group number for POWER status codes. */
|
||||
kStatusGroup_ENET = 40, /*!< Group number for ENET status codes. */
|
||||
kStatusGroup_PHY = 41, /*!< Group number for PHY status codes. */
|
||||
kStatusGroup_TRGMUX = 42, /*!< Group number for TRGMUX status codes. */
|
||||
kStatusGroup_SMARTCARD = 43, /*!< Group number for SMARTCARD status codes. */
|
||||
kStatusGroup_LMEM = 44, /*!< Group number for LMEM status codes. */
|
||||
kStatusGroup_QSPI = 45, /*!< Group number for QSPI status codes. */
|
||||
kStatusGroup_DMA = 50, /*!< Group number for DMA status codes. */
|
||||
kStatusGroup_EDMA = 51, /*!< Group number for EDMA status codes. */
|
||||
kStatusGroup_DMAMGR = 52, /*!< Group number for DMAMGR status codes. */
|
||||
kStatusGroup_FLEXCAN = 53, /*!< Group number for FlexCAN status codes. */
|
||||
kStatusGroup_LTC = 54, /*!< Group number for LTC status codes. */
|
||||
kStatusGroup_FLEXIO_CAMERA = 55, /*!< Group number for FLEXIO CAMERA status codes. */
|
||||
kStatusGroup_LPC_SPI = 56, /*!< Group number for LPC_SPI status codes. */
|
||||
kStatusGroup_LPC_USART = 57, /*!< Group number for LPC_USART status codes. */
|
||||
kStatusGroup_DMIC = 58, /*!< Group number for DMIC status codes. */
|
||||
kStatusGroup_SDIF = 59, /*!< Group number for SDIF status codes.*/
|
||||
kStatusGroup_SPIFI = 60, /*!< Group number for SPIFI status codes. */
|
||||
kStatusGroup_OTP = 61, /*!< Group number for OTP status codes. */
|
||||
kStatusGroup_MCAN = 62, /*!< Group number for MCAN status codes. */
|
||||
kStatusGroup_CAAM = 63, /*!< Group number for CAAM status codes. */
|
||||
kStatusGroup_ECSPI = 64, /*!< Group number for ECSPI status codes. */
|
||||
kStatusGroup_USDHC = 65, /*!< Group number for USDHC status codes.*/
|
||||
kStatusGroup_LPC_I2C = 66, /*!< Group number for LPC_I2C status codes.*/
|
||||
kStatusGroup_DCP = 67, /*!< Group number for DCP status codes.*/
|
||||
kStatusGroup_MSCAN = 68, /*!< Group number for MSCAN status codes.*/
|
||||
kStatusGroup_ESAI = 69, /*!< Group number for ESAI status codes. */
|
||||
kStatusGroup_FLEXSPI = 70, /*!< Group number for FLEXSPI status codes. */
|
||||
kStatusGroup_MMDC = 71, /*!< Group number for MMDC status codes. */
|
||||
kStatusGroup_PDM = 72, /*!< Group number for MIC status codes. */
|
||||
kStatusGroup_SDMA = 73, /*!< Group number for SDMA status codes. */
|
||||
kStatusGroup_ICS = 74, /*!< Group number for ICS status codes. */
|
||||
kStatusGroup_SPDIF = 75, /*!< Group number for SPDIF status codes. */
|
||||
kStatusGroup_LPC_MINISPI = 76, /*!< Group number for LPC_MINISPI status codes. */
|
||||
kStatusGroup_HASHCRYPT = 77, /*!< Group number for Hashcrypt status codes */
|
||||
kStatusGroup_LPC_SPI_SSP = 78, /*!< Group number for LPC_SPI_SSP status codes. */
|
||||
kStatusGroup_I3C = 79, /*!< Group number for I3C status codes */
|
||||
kStatusGroup_LPC_I2C_1 = 97, /*!< Group number for LPC_I2C_1 status codes. */
|
||||
kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */
|
||||
kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */
|
||||
kStatusGroup_SEMC = 100, /*!< Group number for SEMC status codes. */
|
||||
kStatusGroup_ApplicationRangeStart = 101, /*!< Starting number for application groups. */
|
||||
kStatusGroup_IAP = 102, /*!< Group number for IAP status codes */
|
||||
kStatusGroup_SFA = 103, /*!< Group number for SFA status codes*/
|
||||
kStatusGroup_SPC = 104, /*!< Group number for SPC status codes. */
|
||||
kStatusGroup_PUF = 105, /*!< Group number for PUF status codes. */
|
||||
kStatusGroup_TOUCH_PANEL = 106, /*!< Group number for touch panel status codes */
|
||||
|
||||
kStatusGroup_HAL_GPIO = 121, /*!< Group number for HAL GPIO status codes. */
|
||||
kStatusGroup_HAL_UART = 122, /*!< Group number for HAL UART status codes. */
|
||||
kStatusGroup_HAL_TIMER = 123, /*!< Group number for HAL TIMER status codes. */
|
||||
kStatusGroup_HAL_SPI = 124, /*!< Group number for HAL SPI status codes. */
|
||||
kStatusGroup_HAL_I2C = 125, /*!< Group number for HAL I2C status codes. */
|
||||
kStatusGroup_HAL_FLASH = 126, /*!< Group number for HAL FLASH status codes. */
|
||||
kStatusGroup_HAL_PWM = 127, /*!< Group number for HAL PWM status codes. */
|
||||
kStatusGroup_HAL_RNG = 128, /*!< Group number for HAL RNG status codes. */
|
||||
kStatusGroup_TIMERMANAGER = 135, /*!< Group number for TiMER MANAGER status codes. */
|
||||
kStatusGroup_SERIALMANAGER = 136, /*!< Group number for SERIAL MANAGER status codes. */
|
||||
kStatusGroup_LED = 137, /*!< Group number for LED status codes. */
|
||||
kStatusGroup_BUTTON = 138, /*!< Group number for BUTTON status codes. */
|
||||
kStatusGroup_EXTERN_EEPROM = 139, /*!< Group number for EXTERN EEPROM status codes. */
|
||||
kStatusGroup_SHELL = 140, /*!< Group number for SHELL status codes. */
|
||||
kStatusGroup_MEM_MANAGER = 141, /*!< Group number for MEM MANAGER status codes. */
|
||||
kStatusGroup_LIST = 142, /*!< Group number for List status codes. */
|
||||
kStatusGroup_OSA = 143, /*!< Group number for OSA status codes. */
|
||||
kStatusGroup_COMMON_TASK = 144, /*!< Group number for Common task status codes. */
|
||||
kStatusGroup_MSG = 145, /*!< Group number for messaging status codes. */
|
||||
kStatusGroup_SDK_OCOTP = 146, /*!< Group number for OCOTP status codes. */
|
||||
kStatusGroup_SDK_FLEXSPINOR = 147, /*!< Group number for FLEXSPINOR status codes.*/
|
||||
kStatusGroup_CODEC = 148, /*!< Group number for codec status codes. */
|
||||
kStatusGroup_ASRC = 149, /*!< Group number for codec status ASRC. */
|
||||
kStatusGroup_OTFAD = 150, /*!< Group number for codec status codes. */
|
||||
kStatusGroup_SDIOSLV = 151, /*!< Group number for SDIOSLV status codes. */
|
||||
kStatusGroup_MECC = 152, /*!< Group number for MECC status codes. */
|
||||
kStatusGroup_ENET_QOS = 153, /*!< Group number for ENET_QOS status codes. */
|
||||
kStatusGroup_LOG = 154, /*!< Group number for LOG status codes. */
|
||||
kStatusGroup_I3CBUS = 155, /*!< Group number for I3CBUS status codes. */
|
||||
kStatusGroup_QSCI = 156, /*!< Group number for QSCI status codes. */
|
||||
kStatusGroup_SNT = 157, /*!< Group number for SNT status codes. */
|
||||
};
|
||||
|
||||
/*! \public
|
||||
* @brief Generic status return codes.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0), /*!< Generic status for Success. */
|
||||
kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1), /*!< Generic status for Fail. */
|
||||
kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2), /*!< Generic status for read only failure. */
|
||||
kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3), /*!< Generic status for out of range access. */
|
||||
kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4), /*!< Generic status for invalid argument check. */
|
||||
kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5), /*!< Generic status for timeout. */
|
||||
kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6), /*!< Generic status for no transfer in progress. */
|
||||
kStatus_Busy = MAKE_STATUS(kStatusGroup_Generic, 7), /*!< Generic status for module is busy. */
|
||||
};
|
||||
|
||||
/*! @brief Type used for all status and error return values. */
|
||||
typedef int32_t status_t;
|
||||
|
||||
/*!
|
||||
* @name Min/max macros
|
||||
* @{
|
||||
*/
|
||||
#if !defined(MIN)
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if !defined(MAX)
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @brief Computes the number of elements in an array. */
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/*! @name UINT16_MAX/UINT32_MAX value */
|
||||
/* @{ */
|
||||
#if !defined(UINT16_MAX)
|
||||
#define UINT16_MAX ((uint16_t)-1)
|
||||
#endif
|
||||
|
||||
#if !defined(UINT32_MAX)
|
||||
#define UINT32_MAX ((uint32_t)-1)
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Suppress fallthrough warning macro */
|
||||
/* For switch case code block, if case section ends without "break;" statement, there wil be
|
||||
fallthrough warning with compiler flag -Wextra or -Wimplicit-fallthrough=n when using armgcc.
|
||||
To suppress this warning, "SUPPRESS_FALL_THROUGH_WARNING();" need to be added at the end of each
|
||||
case section which misses "break;"statement.
|
||||
*/
|
||||
/* @{ */
|
||||
#if defined(__GNUC__) && !defined(__ARMCC_VERSION)
|
||||
#define SUPPRESS_FALL_THROUGH_WARNING() __attribute__ ((fallthrough))
|
||||
#else
|
||||
#define SUPPRESS_FALL_THROUGH_WARNING()
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Allocate memory with given alignment and aligned size.
|
||||
*
|
||||
* This is provided to support the dynamically allocated memory
|
||||
* used in cache-able region.
|
||||
* @param size The length required to malloc.
|
||||
* @param alignbytes The alignment size.
|
||||
* @retval The allocated memory.
|
||||
*/
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes);
|
||||
|
||||
/*!
|
||||
* @brief Free memory.
|
||||
*
|
||||
* @param ptr The memory to be release.
|
||||
*/
|
||||
void SDK_Free(void *ptr);
|
||||
|
||||
/*!
|
||||
* @brief Delay at least for some time.
|
||||
* Please note that, this API uses while loop for delay, different run-time environments make the time not precise,
|
||||
* if precise delay count was needed, please implement a new delay function with hardware timer.
|
||||
*
|
||||
* @param delayTime_us Delay time in unit of microsecond.
|
||||
* @param coreClock_Hz Core clock frequency with Hz.
|
||||
*/
|
||||
void SDK_DelayAtLeastUs(uint32_t delayTime_us, uint32_t coreClock_Hz);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if (defined(__DSC__) && defined(__CW__))
|
||||
#include "fsl_common_dsc.h"
|
||||
#elif defined(__XCC__)
|
||||
#include "fsl_common_dsp.h"
|
||||
#else
|
||||
#include "fsl_common_arm.h"
|
||||
#endif
|
||||
|
||||
#endif /* _FSL_COMMON_H_ */
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2021 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.common_arm"
|
||||
#endif
|
||||
|
||||
#ifndef __GIC_PRIO_BITS
|
||||
#if defined(ENABLE_RAM_VECTOR_TABLE)
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler)
|
||||
{
|
||||
#ifdef __VECTOR_TABLE
|
||||
#undef __VECTOR_TABLE
|
||||
#endif
|
||||
|
||||
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
extern uint32_t Image$$VECTOR_ROM$$Base[];
|
||||
extern uint32_t Image$$VECTOR_RAM$$Base[];
|
||||
extern uint32_t Image$$RW_m_data$$Base[];
|
||||
|
||||
#define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
|
||||
#define __VECTOR_RAM Image$$VECTOR_RAM$$Base
|
||||
#define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
|
||||
uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES);
|
||||
#endif /* defined(__CC_ARM) || defined(__ARMCC_VERSION) */
|
||||
uint32_t n;
|
||||
uint32_t ret;
|
||||
uint32_t irqMaskValue;
|
||||
|
||||
irqMaskValue = DisableGlobalIRQ();
|
||||
if (SCB->VTOR != (uint32_t)__VECTOR_RAM)
|
||||
{
|
||||
/* Copy the vector table from ROM to RAM */
|
||||
for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++)
|
||||
{
|
||||
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
|
||||
}
|
||||
/* Point the VTOR to the position of vector table */
|
||||
SCB->VTOR = (uint32_t)__VECTOR_RAM;
|
||||
}
|
||||
|
||||
ret = __VECTOR_RAM[(int32_t)irq + 16];
|
||||
/* make sure the __VECTOR_RAM is noncachable */
|
||||
__VECTOR_RAM[(int32_t)irq + 16] = irqHandler;
|
||||
|
||||
EnableGlobalIRQ(irqMaskValue);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* ENABLE_RAM_VECTOR_TABLE. */
|
||||
#endif /* __GIC_PRIO_BITS. */
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
|
||||
/*
|
||||
* When FSL_FEATURE_POWERLIB_EXTEND is defined to non-zero value,
|
||||
* powerlib should be used instead of these functions.
|
||||
*/
|
||||
#if !(defined(FSL_FEATURE_POWERLIB_EXTEND) && (FSL_FEATURE_POWERLIB_EXTEND != 0))
|
||||
|
||||
/*
|
||||
* When the SYSCON STARTER registers are discontinuous, these functions are
|
||||
* implemented in fsl_power.c.
|
||||
*/
|
||||
#if !(defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS)
|
||||
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERSET[index] = 1UL << intNumber;
|
||||
(void)EnableIRQ(interrupt); /* also enable interrupt at NVIC */
|
||||
}
|
||||
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
(void)DisableIRQ(interrupt); /* also disable interrupt at NVIC */
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERCLR[index] = 1UL << intNumber;
|
||||
}
|
||||
#endif /* FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS */
|
||||
#endif /* FSL_FEATURE_POWERLIB_EXTEND */
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
#if defined(SDK_DELAY_USE_DWT) && defined(DWT)
|
||||
/* Use WDT. */
|
||||
static void enableCpuCycleCounter(void)
|
||||
{
|
||||
/* Make sure the DWT trace fucntion is enabled. */
|
||||
if (CoreDebug_DEMCR_TRCENA_Msk != (CoreDebug_DEMCR_TRCENA_Msk & CoreDebug->DEMCR))
|
||||
{
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
}
|
||||
|
||||
/* CYCCNT not supported on this device. */
|
||||
assert(DWT_CTRL_NOCYCCNT_Msk != (DWT->CTRL & DWT_CTRL_NOCYCCNT_Msk));
|
||||
|
||||
/* Read CYCCNT directly if CYCCENT has already been enabled, otherwise enable CYCCENT first. */
|
||||
if (DWT_CTRL_CYCCNTENA_Msk != (DWT_CTRL_CYCCNTENA_Msk & DWT->CTRL))
|
||||
{
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t getCpuCycleCount(void)
|
||||
{
|
||||
return DWT->CYCCNT;
|
||||
}
|
||||
#else /* defined(SDK_DELAY_USE_DWT) && defined(DWT) */
|
||||
/* Use software loop. */
|
||||
#if defined(__CC_ARM) /* This macro is arm v5 specific */
|
||||
/* clang-format off */
|
||||
__ASM static void DelayLoop(uint32_t count)
|
||||
{
|
||||
loop
|
||||
SUBS R0, R0, #1
|
||||
CMP R0, #0
|
||||
BNE loop
|
||||
BX LR
|
||||
}
|
||||
/* clang-format on */
|
||||
#elif defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__GNUC__)
|
||||
/* Cortex-M0 has a smaller instruction set, SUBS isn't supported in thumb-16 mode reported from __GNUC__ compiler,
|
||||
* use SUB and CMP here for compatibility */
|
||||
static void DelayLoop(uint32_t count)
|
||||
{
|
||||
__ASM volatile(" MOV R0, %0" : : "r"(count));
|
||||
__ASM volatile(
|
||||
"loop: \n"
|
||||
#if defined(__GNUC__) && !defined(__ARMCC_VERSION)
|
||||
" SUB R0, R0, #1 \n"
|
||||
#else
|
||||
" SUBS R0, R0, #1 \n"
|
||||
#endif
|
||||
" CMP R0, #0 \n"
|
||||
|
||||
" BNE loop \n"
|
||||
:
|
||||
:
|
||||
: "r0");
|
||||
}
|
||||
#endif /* defined(__CC_ARM) */
|
||||
#endif /* defined(SDK_DELAY_USE_DWT) && defined(DWT) */
|
||||
|
||||
/*!
|
||||
* @brief Delay at least for some time.
|
||||
* Please note that, if not uses DWT, this API will use while loop for delay, different run-time environments have
|
||||
* effect on the delay time. If precise delay is needed, please enable DWT delay. The two parmeters delayTime_us and
|
||||
* coreClock_Hz have limitation. For example, in the platform with 1GHz coreClock_Hz, the delayTime_us only supports
|
||||
* up to 4294967 in current code. If long time delay is needed, please implement a new delay function.
|
||||
*
|
||||
* @param delayTime_us Delay time in unit of microsecond.
|
||||
* @param coreClock_Hz Core clock frequency with Hz.
|
||||
*/
|
||||
void SDK_DelayAtLeastUs(uint32_t delayTime_us, uint32_t coreClock_Hz)
|
||||
{
|
||||
uint64_t count;
|
||||
|
||||
if (delayTime_us > 0U)
|
||||
{
|
||||
count = USEC_TO_COUNT(delayTime_us, coreClock_Hz);
|
||||
|
||||
assert(count <= UINT32_MAX);
|
||||
|
||||
#if defined(SDK_DELAY_USE_DWT) && defined(DWT) /* Use DWT for better accuracy */
|
||||
|
||||
enableCpuCycleCounter();
|
||||
/* Calculate the count ticks. */
|
||||
count += getCpuCycleCount();
|
||||
|
||||
if (count > UINT32_MAX)
|
||||
{
|
||||
count -= UINT32_MAX;
|
||||
/* Wait for cyccnt overflow. */
|
||||
while (count < getCpuCycleCount())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for cyccnt reach count value. */
|
||||
while (count > getCpuCycleCount())
|
||||
{
|
||||
}
|
||||
#else
|
||||
/* Divide value may be different in various environment to ensure delay is precise.
|
||||
* Every loop count includes three instructions, due to Cortex-M7 sometimes executes
|
||||
* two instructions in one period, through test here set divide 1.5. Other M cores use
|
||||
* divide 4. By the way, divide 1.5 or 4 could let the count lose precision, but it does
|
||||
* not matter because other instructions outside while loop is enough to fill the time.
|
||||
*/
|
||||
#if (__CORTEX_M == 7)
|
||||
count = count / 3U * 2U;
|
||||
#else
|
||||
count = count / 4U;
|
||||
#endif
|
||||
DelayLoop((uint32_t)count);
|
||||
#endif /* defined(SDK_DELAY_USE_DWT) && defined(DWT) */
|
||||
}
|
||||
}
|
||||
+660
File diff suppressed because it is too large
Load Diff
+412
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_flexcomm.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.flexcomm"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Used for conversion between `void*` and `uint32_t`.
|
||||
*/
|
||||
typedef union pvoid_to_u32
|
||||
{
|
||||
void *pvoid;
|
||||
uint32_t u32;
|
||||
} pvoid_to_u32_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
/*! @brief Set the FLEXCOMM mode . */
|
||||
static status_t FLEXCOMM_SetPeriph(FLEXCOMM_Type *base, FLEXCOMM_PERIPH_T periph, int lock);
|
||||
|
||||
/*! @brief check whether flexcomm supports peripheral type */
|
||||
static bool FLEXCOMM_PeripheralIsPresent(FLEXCOMM_Type *base, FLEXCOMM_PERIPH_T periph);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Array to map FLEXCOMM instance number to base address. */
|
||||
static const uint32_t s_flexcommBaseAddrs[] = FLEXCOMM_BASE_ADDRS;
|
||||
|
||||
/*! @brief Pointers to real IRQ handlers installed by drivers for each instance. */
|
||||
static flexcomm_irq_handler_t s_flexcommIrqHandler[ARRAY_SIZE(s_flexcommBaseAddrs)];
|
||||
|
||||
/*! @brief Pointers to handles for each instance to provide context to interrupt routines */
|
||||
static void *s_flexcommHandle[ARRAY_SIZE(s_flexcommBaseAddrs)];
|
||||
|
||||
/*! @brief Array to map FLEXCOMM instance number to IRQ number. */
|
||||
IRQn_Type const kFlexcommIrqs[] = FLEXCOMM_IRQS;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief IDs of clock for each FLEXCOMM module */
|
||||
static const clock_ip_name_t s_flexcommClocks[] = FLEXCOMM_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
#if !(defined(FSL_FEATURE_FLEXCOMM_HAS_NO_RESET) && FSL_FEATURE_FLEXCOMM_HAS_NO_RESET)
|
||||
/*! @brief Pointers to FLEXCOMM resets for each instance. */
|
||||
static const reset_ip_name_t s_flexcommResets[] = FLEXCOMM_RSTS;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
/* check whether flexcomm supports peripheral type */
|
||||
static bool FLEXCOMM_PeripheralIsPresent(FLEXCOMM_Type *base, FLEXCOMM_PERIPH_T periph)
|
||||
{
|
||||
if (periph == FLEXCOMM_PERIPH_NONE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (periph <= FLEXCOMM_PERIPH_I2S_TX)
|
||||
{
|
||||
return (base->PSELID & (1UL << ((uint32_t)periph + 3U))) > 0UL ? true : false;
|
||||
}
|
||||
else if (periph == FLEXCOMM_PERIPH_I2S_RX)
|
||||
{
|
||||
return (base->PSELID & (1U << 7U)) > (uint32_t)0U ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the index corresponding to the FLEXCOMM */
|
||||
/*! brief Returns instance number for FLEXCOMM module with given base address. */
|
||||
uint32_t FLEXCOMM_GetInstance(void *base)
|
||||
{
|
||||
uint32_t i;
|
||||
pvoid_to_u32_t BaseAddr;
|
||||
BaseAddr.pvoid = base;
|
||||
|
||||
for (i = 0U; i < (uint32_t)FSL_FEATURE_SOC_FLEXCOMM_COUNT; i++)
|
||||
{
|
||||
if (BaseAddr.u32 == s_flexcommBaseAddrs[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(i < (uint32_t)FSL_FEATURE_SOC_FLEXCOMM_COUNT);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Changes FLEXCOMM mode */
|
||||
static status_t FLEXCOMM_SetPeriph(FLEXCOMM_Type *base, FLEXCOMM_PERIPH_T periph, int lock)
|
||||
{
|
||||
/* Check whether peripheral type is present */
|
||||
if (!FLEXCOMM_PeripheralIsPresent(base, periph))
|
||||
{
|
||||
return kStatus_OutOfRange;
|
||||
}
|
||||
|
||||
/* Flexcomm is locked to different peripheral type than expected */
|
||||
if (((base->PSELID & FLEXCOMM_PSELID_LOCK_MASK) != 0U) &&
|
||||
((base->PSELID & FLEXCOMM_PSELID_PERSEL_MASK) != (uint32_t)periph))
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
|
||||
/* Check if we are asked to lock */
|
||||
if (lock != 0)
|
||||
{
|
||||
base->PSELID = (uint32_t)periph | FLEXCOMM_PSELID_LOCK_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->PSELID = (uint32_t)periph;
|
||||
}
|
||||
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
/*! brief Initializes FLEXCOMM and selects peripheral mode according to the second parameter. */
|
||||
status_t FLEXCOMM_Init(void *base, FLEXCOMM_PERIPH_T periph)
|
||||
{
|
||||
uint32_t idx = FLEXCOMM_GetInstance(base);
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Enable the peripheral clock */
|
||||
CLOCK_EnableClock(s_flexcommClocks[idx]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
#if !(defined(FSL_FEATURE_FLEXCOMM_HAS_NO_RESET) && FSL_FEATURE_FLEXCOMM_HAS_NO_RESET)
|
||||
/* Reset the FLEXCOMM module */
|
||||
RESET_PeripheralReset(s_flexcommResets[idx]);
|
||||
#endif
|
||||
|
||||
/* Set the FLEXCOMM to given peripheral */
|
||||
return FLEXCOMM_SetPeriph((FLEXCOMM_Type *)base, periph, 0);
|
||||
}
|
||||
|
||||
/*! brief Sets IRQ handler for given FLEXCOMM module. It is used by drivers register IRQ handler according to FLEXCOMM
|
||||
* mode */
|
||||
void FLEXCOMM_SetIRQHandler(void *base, flexcomm_irq_handler_t handler, void *flexcommHandle)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(base);
|
||||
|
||||
/* Clear handler first to avoid execution of the handler with wrong handle */
|
||||
s_flexcommIrqHandler[instance] = NULL;
|
||||
s_flexcommHandle[instance] = flexcommHandle;
|
||||
s_flexcommIrqHandler[instance] = handler;
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
|
||||
/* IRQ handler functions overloading weak symbols in the startup */
|
||||
#if defined(FLEXCOMM0)
|
||||
void FLEXCOMM0_DriverIRQHandler(void);
|
||||
void FLEXCOMM0_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM0);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM1)
|
||||
void FLEXCOMM1_DriverIRQHandler(void);
|
||||
void FLEXCOMM1_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM1);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM2)
|
||||
void FLEXCOMM2_DriverIRQHandler(void);
|
||||
void FLEXCOMM2_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM2);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM3)
|
||||
void FLEXCOMM3_DriverIRQHandler(void);
|
||||
void FLEXCOMM3_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM3);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM4)
|
||||
void FLEXCOMM4_DriverIRQHandler(void);
|
||||
void FLEXCOMM4_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM4);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM5)
|
||||
void FLEXCOMM5_DriverIRQHandler(void);
|
||||
void FLEXCOMM5_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM5);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM6)
|
||||
void FLEXCOMM6_DriverIRQHandler(void);
|
||||
void FLEXCOMM6_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM6);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM7)
|
||||
void FLEXCOMM7_DriverIRQHandler(void);
|
||||
void FLEXCOMM7_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM7);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM8)
|
||||
void FLEXCOMM8_DriverIRQHandler(void);
|
||||
void FLEXCOMM8_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM8);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM9)
|
||||
void FLEXCOMM9_DriverIRQHandler(void);
|
||||
void FLEXCOMM9_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM9);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM10)
|
||||
void FLEXCOMM10_DriverIRQHandler(void);
|
||||
void FLEXCOMM10_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM10);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM11)
|
||||
void FLEXCOMM11_DriverIRQHandler(void);
|
||||
void FLEXCOMM11_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM11);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM12)
|
||||
void FLEXCOMM12_DriverIRQHandler(void);
|
||||
void FLEXCOMM12_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM12);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM13)
|
||||
void FLEXCOMM13_DriverIRQHandler(void);
|
||||
void FLEXCOMM13_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM13);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM14)
|
||||
void FLEXCOMM14_DriverIRQHandler(void);
|
||||
void FLEXCOMM14_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM14);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM15)
|
||||
void FLEXCOMM15_DriverIRQHandler(void);
|
||||
void FLEXCOMM15_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM15);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLEXCOMM16)
|
||||
void FLEXCOMM16_DriverIRQHandler(void);
|
||||
void FLEXCOMM16_DriverIRQHandler(void)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Look up instance number */
|
||||
instance = FLEXCOMM_GetInstance(FLEXCOMM16);
|
||||
assert(s_flexcommIrqHandler[instance] != NULL);
|
||||
s_flexcommIrqHandler[instance]((uint32_t *)s_flexcommBaseAddrs[instance], s_flexcommHandle[instance]);
|
||||
SDK_ISR_EXIT_BARRIER;
|
||||
}
|
||||
#endif
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXCOMM_H_
|
||||
#define _FSL_FLEXCOMM_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexcomm_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexCOMM driver version 2.0.2. */
|
||||
#define FSL_FLEXCOMM_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief FLEXCOMM peripheral modes. */
|
||||
typedef enum
|
||||
{
|
||||
FLEXCOMM_PERIPH_NONE, /*!< No peripheral */
|
||||
FLEXCOMM_PERIPH_USART, /*!< USART peripheral */
|
||||
FLEXCOMM_PERIPH_SPI, /*!< SPI Peripheral */
|
||||
FLEXCOMM_PERIPH_I2C, /*!< I2C Peripheral */
|
||||
FLEXCOMM_PERIPH_I2S_TX, /*!< I2S TX Peripheral */
|
||||
FLEXCOMM_PERIPH_I2S_RX, /*!< I2S RX Peripheral */
|
||||
} FLEXCOMM_PERIPH_T;
|
||||
|
||||
/*! @brief Typedef for interrupt handler. */
|
||||
typedef void (*flexcomm_irq_handler_t)(void *base, void *handle);
|
||||
|
||||
/*! @brief Array with IRQ number for each FLEXCOMM module. */
|
||||
extern IRQn_Type const kFlexcommIrqs[];
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! @brief Returns instance number for FLEXCOMM module with given base address. */
|
||||
uint32_t FLEXCOMM_GetInstance(void *base);
|
||||
|
||||
/*! @brief Initializes FLEXCOMM and selects peripheral mode according to the second parameter. */
|
||||
status_t FLEXCOMM_Init(void *base, FLEXCOMM_PERIPH_T periph);
|
||||
|
||||
/*! @brief Sets IRQ handler for given FLEXCOMM module. It is used by drivers register IRQ handler according to FLEXCOMM
|
||||
* mode */
|
||||
void FLEXCOMM_SetIRQHandler(void *base, flexcomm_irq_handler_t handler, void *flexcommHandle);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* _FSL_FLEXCOMM_H_*/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user