Skip to content

Commit a6d46bb

Browse files
committed
Implement a new example : OpenAMP_FreeRTOS
1 parent ec4524e commit a6d46bb

60 files changed

Lines changed: 10748 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/* USER CODE BEGIN Header */
2+
/*
3+
* FreeRTOS Kernel V10.0.1
4+
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
* http://www.FreeRTOS.org
24+
* http://aws.amazon.com/freertos
25+
*
26+
* 1 tab == 4 spaces!
27+
*/
28+
/* USER CODE END Header */
29+
30+
#ifndef FREERTOS_CONFIG_H
31+
#define FREERTOS_CONFIG_H
32+
33+
/*-----------------------------------------------------------
34+
* Application specific definitions.
35+
*
36+
* These definitions should be adjusted for your particular hardware and
37+
* application requirements.
38+
*
39+
* These parameters and more are described within the 'configuration' section of the
40+
* FreeRTOS API documentation available on the FreeRTOS.org web site.
41+
*
42+
* See http://www.freertos.org/a00110.html
43+
*----------------------------------------------------------*/
44+
45+
/* USER CODE BEGIN Includes */
46+
/* Section where include file can be added */
47+
/* USER CODE END Includes */
48+
49+
/* Ensure definitions are only used by the compiler, and not by the assembler. */
50+
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
51+
#include <stdint.h>
52+
extern uint32_t SystemCoreClock;
53+
#endif
54+
#define configUSE_PREEMPTION 1
55+
#define configSUPPORT_STATIC_ALLOCATION 1
56+
#define configSUPPORT_DYNAMIC_ALLOCATION 1
57+
#define configUSE_IDLE_HOOK 0
58+
#define configUSE_TICK_HOOK 0
59+
#define configCPU_CLOCK_HZ ( SystemCoreClock )
60+
#define configTICK_RATE_HZ ((TickType_t)1000)
61+
#define configMAX_PRIORITIES ( 56 )
62+
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
63+
#define configTOTAL_HEAP_SIZE ((size_t)3072)
64+
#define configMAX_TASK_NAME_LEN ( 16 )
65+
#define configUSE_TRACE_FACILITY 1
66+
#define configUSE_16_BIT_TICKS 0
67+
#define configUSE_MUTEXES 1
68+
#define configQUEUE_REGISTRY_SIZE 8
69+
#define configUSE_RECURSIVE_MUTEXES 1
70+
#define configUSE_COUNTING_SEMAPHORES 1
71+
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
72+
73+
/* Co-routine definitions. */
74+
#define configUSE_CO_ROUTINES 0
75+
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
76+
77+
/* Software timer definitions. */
78+
#define configUSE_TIMERS 1
79+
#define configTIMER_TASK_PRIORITY ( 2 )
80+
#define configTIMER_QUEUE_LENGTH 10
81+
#define configTIMER_TASK_STACK_DEPTH 256
82+
83+
/* Set the following definitions to 1 to include the API function, or zero
84+
to exclude the API function. */
85+
#define INCLUDE_vTaskPrioritySet 1
86+
#define INCLUDE_uxTaskPriorityGet 1
87+
#define INCLUDE_vTaskDelete 1
88+
#define INCLUDE_vTaskCleanUpResources 0
89+
#define INCLUDE_vTaskSuspend 1
90+
#define INCLUDE_vTaskDelayUntil 1
91+
#define INCLUDE_vTaskDelay 1
92+
#define INCLUDE_xTaskGetSchedulerState 1
93+
#define INCLUDE_xTimerPendFunctionCall 1
94+
#define INCLUDE_xQueueGetMutexHolder 1
95+
#define INCLUDE_uxTaskGetStackHighWaterMark 1
96+
#define INCLUDE_eTaskGetState 1
97+
98+
/*
99+
* The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
100+
* by the application thus the correct define need to be enabled below
101+
*/
102+
#define USE_FreeRTOS_HEAP_4
103+
104+
/* Cortex-M specific definitions. */
105+
#ifdef __NVIC_PRIO_BITS
106+
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
107+
#define configPRIO_BITS __NVIC_PRIO_BITS
108+
#else
109+
#define configPRIO_BITS 4
110+
#endif
111+
112+
/* The lowest interrupt priority that can be used in a call to a "set priority"
113+
function. */
114+
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
115+
116+
/* The highest interrupt priority that can be used by any interrupt service
117+
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
118+
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
119+
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
120+
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
121+
122+
/* Interrupt priorities used by the kernel port layer itself. These are generic
123+
to all Cortex-M ports, and do not rely on any particular library functions. */
124+
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
125+
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
126+
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
127+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
128+
129+
/* Normal assert() semantics without relying on the provision of an assert.h
130+
header file. */
131+
/* USER CODE BEGIN 1 */
132+
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
133+
/* USER CODE END 1 */
134+
135+
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
136+
standard names. */
137+
#define vPortSVCHandler SVC_Handler
138+
#define xPortPendSVHandler PendSV_Handler
139+
140+
/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
141+
to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
142+
#define xPortSysTickHandler SysTick_Handler
143+
144+
/* USER CODE BEGIN Defines */
145+
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
146+
/* USER CODE END Defines */
147+
148+
#endif /* FREERTOS_CONFIG_H */
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
******************************************************************************
3+
* @file lock_resource.h
4+
* @author MCD Application Team
5+
* @brief Header for lock_resource.c
6+
******************************************************************************
7+
* @attention
8+
*
9+
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10+
* All rights reserved.</center></h2>
11+
*
12+
* This software component is licensed by ST under BSD 3-Clause license,
13+
* the "License"; You may not use this file except in compliance with the
14+
* License. You may obtain a copy of the License at:
15+
* opensource.org/licenses/BSD-3-Clause
16+
*
17+
******************************************************************************
18+
*/
19+
/* Define to prevent recursive inclusion -------------------------------------*/
20+
#ifndef __LOCK_RESOURCE_H__
21+
#define __LOCK_RESOURCE_H__
22+
23+
/* Includes ------------------------------------------------------------------*/
24+
#include "stm32mp1xx_hal.h"
25+
26+
27+
/* Exported types ------------------------------------------------------------*/
28+
typedef enum
29+
{
30+
LOCK_RESOURCE_STATUS_OK = 0x00U,
31+
LOCK_RESOURCE_STATUS_ERROR = 0x01U,
32+
LOCK_RESOURCE_STATUS_TIMEOUT = 0x02U
33+
} LockResource_Status_t;
34+
35+
/* Exported constants --------------------------------------------------------*/
36+
#define LOCK_RESOURCE_TIMEOUT 100U /* timeout in ms */
37+
38+
/* Exported macro ------------------------------------------------------------*/
39+
#define PERIPH_LOCK(__Periph__) Periph_Lock(__Periph__, LOCK_RESOURCE_TIMEOUT)
40+
#define PERIPH_UNLOCK(__Periph__) Periph_Unlock(__Periph__)
41+
42+
/* Exported functions ------------------------------------------------------- */
43+
LockResource_Status_t Periph_Lock(void *Peripheral, uint32_t Timeout);
44+
void Periph_Unlock(void *Peripheral);
45+
46+
47+
48+
49+
#endif /* __LOCK_RESOURCE_H__ */
50+
51+
52+
53+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* USER CODE BEGIN Header */
2+
/**
3+
******************************************************************************
4+
* @file : main.h
5+
* @brief : Header for main.c file.
6+
* This file contains the common defines of the application.
7+
******************************************************************************
8+
* @attention
9+
*
10+
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
11+
* All rights reserved.</center></h2>
12+
*
13+
* This software component is licensed by ST under Ultimate Liberty license
14+
* SLA0044, the "License"; You may not use this file except in compliance with
15+
* the License. You may obtain a copy of the License at:
16+
* www.st.com/SLA0044
17+
*
18+
******************************************************************************
19+
*/
20+
/* USER CODE END Header */
21+
22+
/* Define to prevent recursive inclusion -------------------------------------*/
23+
#ifndef __MAIN_H
24+
#define __MAIN_H
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/* Includes ------------------------------------------------------------------*/
31+
#include "stm32mp1xx_hal.h"
32+
33+
/* Private includes ----------------------------------------------------------*/
34+
/* USER CODE BEGIN Includes */
35+
#include "lock_resource.h"
36+
#include "stm32mp15xx_disco.h"
37+
#include "openamp_log.h"
38+
/* USER CODE END Includes */
39+
40+
/* Exported types ------------------------------------------------------------*/
41+
/* USER CODE BEGIN ET */
42+
43+
/* USER CODE END ET */
44+
45+
/* Exported constants --------------------------------------------------------*/
46+
/* USER CODE BEGIN EC */
47+
48+
/* USER CODE END EC */
49+
50+
/* Exported macro ------------------------------------------------------------*/
51+
/* USER CODE BEGIN EM */
52+
53+
/* USER CODE END EM */
54+
55+
/* Exported functions prototypes ---------------------------------------------*/
56+
void Error_Handler(void);
57+
58+
/* USER CODE BEGIN EFP */
59+
60+
/* USER CODE END EFP */
61+
62+
/* Private defines -----------------------------------------------------------*/
63+
64+
/* USER CODE BEGIN Private defines */
65+
#define MAX_BUFFER_SIZE 512
66+
/* USER CODE END Private defines */
67+
68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
72+
#endif /* __MAIN_H */
73+
74+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
******************************************************************************
3+
* @file : mbox_ipcc.h
4+
* @brief : Header for mailbox_ipcc_if.c module
5+
******************************************************************************
6+
* @attention
7+
*
8+
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
9+
* All rights reserved.</center></h2>
10+
*
11+
* This software component is licensed by ST under Ultimate Liberty license
12+
* SLA0044, the "License"; You may not use this file except in compliance with
13+
* the License. You may obtain a copy of the License at:
14+
* www.st.com/SLA0044
15+
*
16+
******************************************************************************
17+
*/
18+
19+
#ifndef MBOX_IPCC_H_
20+
#define MBOX_IPCC_H_
21+
22+
/* USER CODE BEGIN firstSection */
23+
/* can be used to modify / undefine following code or add new definitions */
24+
/* USER CODE END firstSection */
25+
26+
/* Includes ------------------------------------------------------------------*/
27+
/* Exported types ------------------------------------------------------------*/
28+
/* Exported constants --------------------------------------------------------*/
29+
/* Exported functions ------------------------------------------------------- */
30+
int MAILBOX_Notify(void *priv, uint32_t id);
31+
int MAILBOX_Init(void);
32+
int MAILBOX_Poll(struct virtio_device *vdev);
33+
34+
/* USER CODE BEGIN lastSection */
35+
/* can be used to modify / undefine previous code or add new definitions */
36+
/* USER CODE END lastSection */
37+
38+
#endif /* MBOX_IPCC_H_ */
39+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
******************************************************************************
3+
* @file : openamp.h
4+
* @brief : Header for openamp applications
5+
* @author : MCD Application Team
6+
******************************************************************************
7+
* @attention
8+
*
9+
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10+
* All rights reserved.</center></h2>
11+
*
12+
* This software component is licensed by ST under Ultimate Liberty license
13+
* SLA0044, the "License"; You may not use this file except in compliance with
14+
* the License. You may obtain a copy of the License at:
15+
* www.st.com/SLA0044
16+
*
17+
******************************************************************************
18+
*/
19+
20+
/* Define to prevent recursive inclusion -------------------------------------*/
21+
#ifndef __openamp_H
22+
#define __openamp_H
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
#include "openamp/open_amp.h"
29+
#include "openamp_conf.h"
30+
31+
#define OPENAMP_send rpmsg_send
32+
#define OPENAMP_destroy_ept rpmsg_destroy_ept
33+
34+
/* Initialize the openamp framework*/
35+
int MX_OPENAMP_Init(int RPMsgRole, rpmsg_ns_bind_cb ns_bind_cb);
36+
37+
/* Deinitialize the openamp framework*/
38+
void OPENAMP_DeInit();
39+
40+
/* Initialize the endpoint struct*/
41+
void OPENAMP_init_ept(struct rpmsg_endpoint *ept);
42+
43+
/* Create and register the endpoint */
44+
int OPENAMP_create_endpoint(struct rpmsg_endpoint *ept, const char *name,
45+
uint32_t dest, rpmsg_ept_cb cb,
46+
rpmsg_ns_unbind_cb unbind_cb);
47+
48+
/* Check for new rpmsg reception */
49+
50+
void OPENAMP_check_for_message(void);
51+
52+
/* Wait loop on endpoint ready ( message dest address is know)*/
53+
void OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept);
54+
55+
#ifdef __cplusplus
56+
}
57+
#endif
58+
#endif /*__openamp_H */
59+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)