Init commit
This commit is contained in:
9
bsp_stm32_rtems/CMakeLists.txt
Normal file
9
bsp_stm32_rtems/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
init.c
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(boardconfig)
|
||||
add_subdirectory(fsfwconfig)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(boardtest)
|
44
bsp_stm32_rtems/RTEMSConfig.h
Normal file
44
bsp_stm32_rtems/RTEMSConfig.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef BSP_STM32_RTEMS_RTEMSCONFIG_H_
|
||||
#define BSP_STM32_RTEMS_RTEMSCONFIG_H_
|
||||
|
||||
#include <rtems/rtems/tasks.h>
|
||||
|
||||
/* Forward declaration required */
|
||||
rtems_task Init(rtems_task_argument argument);
|
||||
|
||||
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
|
||||
|
||||
//! Specify the allocation scheme used for RTEMS.
|
||||
//! See: https://docs.rtems.org/branches/master/c-user/config/intro.html
|
||||
#define RTEMS_USE_UNLIMITED_OBJECTS_ALLOCATION 0
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#if RTEMS_USE_UNLIMITED_OBJECTS_ALLOCATION == 1
|
||||
|
||||
#define CONFIGURE_UNIFIED_WORK_AREAS
|
||||
#define CONFIGURE_UNLIMITED_OBJECTS
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 6)
|
||||
|
||||
#else
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 20
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 30
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 10
|
||||
//! Required for Rate-Monotonic Scheduling (RMS)
|
||||
#define CONFIGURE_MAXIMUM_PERIODS 15
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 6)
|
||||
//! Around 41 kB extra task stack for now.
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
|
||||
#endif /* RTEMS_USE_UNLIMITED_OBJECTS_ALLOCATION == 1 */
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
#endif /* BSP_STM32_RTEMS_RTEMSCONFIG_H_ */
|
11
bsp_stm32_rtems/boardconfig/CMakeLists.txt
Normal file
11
bsp_stm32_rtems/boardconfig/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
stm32h7xx_nucleo.c
|
||||
hardware_init.c
|
||||
led.c
|
||||
lan8742.c
|
||||
stm32h7xx_it.c
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
116
bsp_stm32_rtems/boardconfig/hardware_init.c
Normal file
116
bsp_stm32_rtems/boardconfig/hardware_init.c
Normal file
@ -0,0 +1,116 @@
|
||||
#include "hardware_init.h"
|
||||
#include <OBSWConfig.h>
|
||||
#include <lwipopts.h>
|
||||
|
||||
#include <common/stm32_nucleo/networking/ethernetif.h>
|
||||
#include <common/stm32_nucleo/networking/app_ethernet.h>
|
||||
|
||||
#include <lwip/init.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include <lwip/netif.h>
|
||||
|
||||
#include <netif/ethernet.h>
|
||||
#include <stm32h7xx_nucleo.h>
|
||||
#include <bsp/bootcard.h>
|
||||
|
||||
#include <hal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct netif gnetif;
|
||||
|
||||
void Netif_Config(void);
|
||||
void MPU_Config(void);
|
||||
|
||||
void hardware_init() {
|
||||
/* Configure MPU for networking */
|
||||
MPU_Config();
|
||||
|
||||
BSP_LED_Init(LED1);
|
||||
BSP_LED_Init(LED2);
|
||||
BSP_LED_Init(LED3);
|
||||
|
||||
#if OBSW_ADD_LWIP_NETWORKING == 1
|
||||
/* Initialize the LwIP stack */
|
||||
lwip_init();
|
||||
|
||||
/* Configure the Network interface */
|
||||
Netif_Config();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Netif_Config(void) {
|
||||
ip_addr_t ipaddr;
|
||||
ip_addr_t netmask;
|
||||
ip_addr_t gw;
|
||||
#if LWIP_DHCP == 1
|
||||
ip_addr_set_zero_ip4(&ipaddr);
|
||||
ip_addr_set_zero_ip4(&netmask);
|
||||
ip_addr_set_zero_ip4(&gw);
|
||||
#else
|
||||
|
||||
/* IP address default setting */
|
||||
set_lwip_addresses(&ipaddr, &netmask, &gw);
|
||||
|
||||
#endif
|
||||
|
||||
/* add the network interface */
|
||||
struct netif* netif_valid = netif_add(&gnetif, (ip4_addr_t*)&ipaddr,
|
||||
(ip4_addr_t*)&netmask, (ip4_addr_t*) &gw, NULL, ðernetif_init,
|
||||
ðernet_input);
|
||||
if(netif_valid == NULL) {
|
||||
printf("Error: netif initialization failed!\n\r");
|
||||
return;
|
||||
}
|
||||
/* Registers the default network interface */
|
||||
netif_set_default(&gnetif);
|
||||
|
||||
ethernet_link_status_updated(&gnetif);
|
||||
|
||||
#if LWIP_NETIF_LINK_CALLBACK == 1
|
||||
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Configure the MPU attributes */
|
||||
void MPU_Config(void)
|
||||
{
|
||||
MPU_Region_InitTypeDef MPU_InitStruct;
|
||||
|
||||
/* Disable the MPU */
|
||||
HAL_MPU_Disable();
|
||||
|
||||
/* Configure the MPU attributes as Device not cacheable
|
||||
for ETH DMA descriptors */
|
||||
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
|
||||
MPU_InitStruct.BaseAddress = 0x30040000;
|
||||
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
|
||||
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
|
||||
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
|
||||
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
|
||||
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
|
||||
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
|
||||
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
|
||||
MPU_InitStruct.SubRegionDisable = 0x00;
|
||||
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
|
||||
|
||||
HAL_MPU_ConfigRegion(&MPU_InitStruct);
|
||||
|
||||
/* Configure the MPU attributes as Cacheable write through
|
||||
for LwIP RAM heap which contains the Tx buffers */
|
||||
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
|
||||
MPU_InitStruct.BaseAddress = 0x30044000;
|
||||
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
|
||||
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
|
||||
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
|
||||
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
|
||||
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
|
||||
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
|
||||
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
|
||||
MPU_InitStruct.SubRegionDisable = 0x00;
|
||||
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
|
||||
|
||||
HAL_MPU_ConfigRegion(&MPU_InitStruct);
|
||||
|
||||
/* Enable the MPU */
|
||||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
|
||||
}
|
18
bsp_stm32_rtems/boardconfig/hardware_init.h
Normal file
18
bsp_stm32_rtems/boardconfig/hardware_init.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef BSP_STM32_BOARDCONFIG_HARDWARE_INIT_H_
|
||||
#define BSP_STM32_BOARDCONFIG_HARDWARE_INIT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct netif gnetif; /* network interface structure */
|
||||
|
||||
void hardware_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BSP_STM32_BOARDCONFIG_HARDWARE_INIT_H_ */
|
664
bsp_stm32_rtems/boardconfig/lan8742.c
Normal file
664
bsp_stm32_rtems/boardconfig/lan8742.c
Normal file
@ -0,0 +1,664 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lan8742.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the LAN742
|
||||
* PHY devices.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "lan8742.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742 LAN8742
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/** @defgroup LAN8742_Private_Defines LAN8742 Private Defines
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_SW_RESET_TO ((uint32_t)500U)
|
||||
#define LAN8742_INIT_TO ((uint32_t)2000U)
|
||||
#define LAN8742_MAX_DEV_ADDR ((uint32_t)31U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/** @defgroup LAN8742_Private_Functions LAN8742 Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register IO functions to component object
|
||||
* @param pObj: device object of LAN8742_Object_t.
|
||||
* @param ioctx: holds device IO functions.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_ERROR if missing mandatory function
|
||||
*/
|
||||
int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
|
||||
{
|
||||
if(!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick)
|
||||
{
|
||||
return LAN8742_STATUS_ERROR;
|
||||
}
|
||||
|
||||
pObj->IO.Init = ioctx->Init;
|
||||
pObj->IO.DeInit = ioctx->DeInit;
|
||||
pObj->IO.ReadReg = ioctx->ReadReg;
|
||||
pObj->IO.WriteReg = ioctx->WriteReg;
|
||||
pObj->IO.GetTick = ioctx->GetTick;
|
||||
|
||||
return LAN8742_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the lan8742 and configure the needed hardware resources
|
||||
* @param pObj: device object LAN8742_Object_t.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_ADDRESS_ERROR if cannot find device address
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
* LAN8742_STATUS_RESET_TIMEOUT if cannot perform a software reset
|
||||
*/
|
||||
int32_t LAN8742_Init(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t tickstart = 0, regvalue = 0, addr = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->Is_Initialized == 0)
|
||||
{
|
||||
if(pObj->IO.Init != 0)
|
||||
{
|
||||
/* GPIO and Clocks initialization */
|
||||
pObj->IO.Init();
|
||||
}
|
||||
|
||||
/* for later check */
|
||||
pObj->DevAddr = LAN8742_MAX_DEV_ADDR + 1;
|
||||
|
||||
/* Get the device address from special mode register */
|
||||
for(addr = 0; addr <= LAN8742_MAX_DEV_ADDR; addr ++)
|
||||
{
|
||||
if(pObj->IO.ReadReg(addr, LAN8742_SMR, ®value) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
/* Can't read from this device address
|
||||
continue with next address */
|
||||
continue;
|
||||
}
|
||||
|
||||
if((regvalue & LAN8742_SMR_PHY_ADDR) == addr)
|
||||
{
|
||||
pObj->DevAddr = addr;
|
||||
status = LAN8742_STATUS_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(pObj->DevAddr > LAN8742_MAX_DEV_ADDR)
|
||||
{
|
||||
status = LAN8742_STATUS_ADDRESS_ERROR;
|
||||
}
|
||||
|
||||
/* if device address is matched */
|
||||
if(status == LAN8742_STATUS_OK)
|
||||
{
|
||||
/* set a software reset */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_SOFT_RESET) >= 0)
|
||||
{
|
||||
/* get software reset status */
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) >= 0)
|
||||
{
|
||||
tickstart = pObj->IO.GetTick();
|
||||
|
||||
/* wait until software reset is done or timeout occured */
|
||||
while(regvalue & LAN8742_BCR_SOFT_RESET)
|
||||
{
|
||||
if((pObj->IO.GetTick() - tickstart) <= LAN8742_SW_RESET_TO)
|
||||
{
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_RESET_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(status == LAN8742_STATUS_OK)
|
||||
{
|
||||
tickstart = pObj->IO.GetTick();
|
||||
|
||||
/* Wait for 2s to perform initialization */
|
||||
while((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO)
|
||||
{
|
||||
}
|
||||
pObj->Is_Initialized = 1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief De-Initialize the lan8742 and it's hardware resources
|
||||
* @param pObj: device object LAN8742_Object_t.
|
||||
* @retval None
|
||||
*/
|
||||
int32_t LAN8742_DeInit(lan8742_Object_t *pObj)
|
||||
{
|
||||
if(pObj->Is_Initialized)
|
||||
{
|
||||
if(pObj->IO.DeInit != 0)
|
||||
{
|
||||
if(pObj->IO.DeInit() < 0)
|
||||
{
|
||||
return LAN8742_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pObj->Is_Initialized = 0;
|
||||
}
|
||||
|
||||
return LAN8742_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the LAN8742 power down mode.
|
||||
* @param pObj: device object LAN8742_Object_t.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
||||
{
|
||||
readval &= ~LAN8742_BCR_POWER_DOWN;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the LAN8742 power down mode.
|
||||
* @param pObj: device object LAN8742_Object_t.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
||||
{
|
||||
readval |= LAN8742_BCR_POWER_DOWN;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start the auto negotiation process.
|
||||
* @param pObj: device object LAN8742_Object_t.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
||||
{
|
||||
readval |= LAN8742_BCR_AUTONEGO_EN;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the link state of LAN8742 device.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param pLinkState: Pointer to link state
|
||||
* @retval LAN8742_STATUS_LINK_DOWN if link is down
|
||||
* LAN8742_STATUS_AUTONEGO_NOTDONE if Auto nego not completed
|
||||
* LAN8742_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
|
||||
* LAN8742_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
|
||||
* LAN8742_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
|
||||
* LAN8742_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
|
||||
/* Read Status register */
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
|
||||
{
|
||||
return LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
/* Read Status register again */
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
|
||||
{
|
||||
return LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
if((readval & LAN8742_BSR_LINK_STATUS) == 0)
|
||||
{
|
||||
/* Return Link Down status */
|
||||
return LAN8742_STATUS_LINK_DOWN;
|
||||
}
|
||||
|
||||
/* Check Auto negotiaition */
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) < 0)
|
||||
{
|
||||
return LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
if((readval & LAN8742_BCR_AUTONEGO_EN) != LAN8742_BCR_AUTONEGO_EN)
|
||||
{
|
||||
if(((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT) && ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE))
|
||||
{
|
||||
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
||||
}
|
||||
else if ((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT)
|
||||
{
|
||||
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
||||
}
|
||||
else if ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE)
|
||||
{
|
||||
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
||||
}
|
||||
}
|
||||
else /* Auto Nego enabled */
|
||||
{
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_PHYSCSR, &readval) < 0)
|
||||
{
|
||||
return LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
/* Check if auto nego not done */
|
||||
if((readval & LAN8742_PHYSCSR_AUTONEGO_DONE) == 0)
|
||||
{
|
||||
return LAN8742_STATUS_AUTONEGO_NOTDONE;
|
||||
}
|
||||
|
||||
if((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_FD)
|
||||
{
|
||||
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
||||
}
|
||||
else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_HD)
|
||||
{
|
||||
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
||||
}
|
||||
else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_10BT_FD)
|
||||
{
|
||||
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the link state of LAN8742 device.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param pLinkState: link state can be one of the following
|
||||
* LAN8742_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
|
||||
* LAN8742_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
|
||||
* LAN8742_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
|
||||
* LAN8742_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_ERROR if parameter error
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState)
|
||||
{
|
||||
uint32_t bcrvalue = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &bcrvalue) >= 0)
|
||||
{
|
||||
/* Disable link config (Auto nego, speed and duplex) */
|
||||
bcrvalue &= ~(LAN8742_BCR_AUTONEGO_EN | LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
|
||||
|
||||
if(LinkState == LAN8742_STATUS_100MBITS_FULLDUPLEX)
|
||||
{
|
||||
bcrvalue |= (LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
|
||||
}
|
||||
else if (LinkState == LAN8742_STATUS_100MBITS_HALFDUPLEX)
|
||||
{
|
||||
bcrvalue |= LAN8742_BCR_SPEED_SELECT;
|
||||
}
|
||||
else if (LinkState == LAN8742_STATUS_10MBITS_FULLDUPLEX)
|
||||
{
|
||||
bcrvalue |= LAN8742_BCR_DUPLEX_MODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wrong link status parameter */
|
||||
status = LAN8742_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
if(status == LAN8742_STATUS_OK)
|
||||
{
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, bcrvalue) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable loopback mode.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
||||
{
|
||||
readval |= LAN8742_BCR_LOOPBACK;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable loopback mode.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
||||
{
|
||||
readval &= ~LAN8742_BCR_LOOPBACK;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable IT source.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param Interrupt: IT source to be enabled
|
||||
* should be a value or a combination of the following:
|
||||
* LAN8742_WOL_IT
|
||||
* LAN8742_ENERGYON_IT
|
||||
* LAN8742_AUTONEGO_COMPLETE_IT
|
||||
* LAN8742_REMOTE_FAULT_IT
|
||||
* LAN8742_LINK_DOWN_IT
|
||||
* LAN8742_AUTONEGO_LP_ACK_IT
|
||||
* LAN8742_PARALLEL_DETECTION_FAULT_IT
|
||||
* LAN8742_AUTONEGO_PAGE_RECEIVED_IT
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
|
||||
{
|
||||
readval |= Interrupt;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable IT source.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param Interrupt: IT source to be disabled
|
||||
* should be a value or a combination of the following:
|
||||
* LAN8742_WOL_IT
|
||||
* LAN8742_ENERGYON_IT
|
||||
* LAN8742_AUTONEGO_COMPLETE_IT
|
||||
* LAN8742_REMOTE_FAULT_IT
|
||||
* LAN8742_LINK_DOWN_IT
|
||||
* LAN8742_AUTONEGO_LP_ACK_IT
|
||||
* LAN8742_PARALLEL_DETECTION_FAULT_IT
|
||||
* LAN8742_AUTONEGO_PAGE_RECEIVED_IT
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||
*/
|
||||
int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
|
||||
{
|
||||
readval &= ~Interrupt;
|
||||
|
||||
/* Apply configuration */
|
||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear IT flag.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param Interrupt: IT flag to be cleared
|
||||
* should be a value or a combination of the following:
|
||||
* LAN8742_WOL_IT
|
||||
* LAN8742_ENERGYON_IT
|
||||
* LAN8742_AUTONEGO_COMPLETE_IT
|
||||
* LAN8742_REMOTE_FAULT_IT
|
||||
* LAN8742_LINK_DOWN_IT
|
||||
* LAN8742_AUTONEGO_LP_ACK_IT
|
||||
* LAN8742_PARALLEL_DETECTION_FAULT_IT
|
||||
* LAN8742_AUTONEGO_PAGE_RECEIVED_IT
|
||||
* @retval LAN8742_STATUS_OK if OK
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
*/
|
||||
int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = LAN8742_STATUS_OK;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) < 0)
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get IT Flag status.
|
||||
* @param pObj: Pointer to device object.
|
||||
* @param Interrupt: IT Flag to be checked,
|
||||
* should be a value or a combination of the following:
|
||||
* LAN8742_WOL_IT
|
||||
* LAN8742_ENERGYON_IT
|
||||
* LAN8742_AUTONEGO_COMPLETE_IT
|
||||
* LAN8742_REMOTE_FAULT_IT
|
||||
* LAN8742_LINK_DOWN_IT
|
||||
* LAN8742_AUTONEGO_LP_ACK_IT
|
||||
* LAN8742_PARALLEL_DETECTION_FAULT_IT
|
||||
* LAN8742_AUTONEGO_PAGE_RECEIVED_IT
|
||||
* @retval 1 IT flag is SET
|
||||
* 0 IT flag is RESET
|
||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||
*/
|
||||
int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt)
|
||||
{
|
||||
uint32_t readval = 0;
|
||||
int32_t status = 0;
|
||||
|
||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) >= 0)
|
||||
{
|
||||
status = ((readval & Interrupt) == Interrupt);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = LAN8742_STATUS_READ_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
448
bsp_stm32_rtems/boardconfig/lan8742.h
Normal file
448
bsp_stm32_rtems/boardconfig/lan8742.h
Normal file
@ -0,0 +1,448 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lan8742.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the
|
||||
* lan8742.c PHY driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef LAN8742_H
|
||||
#define LAN8742_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742
|
||||
* @{
|
||||
*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup LAN8742_Exported_Constants LAN8742 Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_Registers_Mapping LAN8742 Registers Mapping
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_BCR ((uint16_t)0x0000U)
|
||||
#define LAN8742_BSR ((uint16_t)0x0001U)
|
||||
#define LAN8742_PHYI1R ((uint16_t)0x0002U)
|
||||
#define LAN8742_PHYI2R ((uint16_t)0x0003U)
|
||||
#define LAN8742_ANAR ((uint16_t)0x0004U)
|
||||
#define LAN8742_ANLPAR ((uint16_t)0x0005U)
|
||||
#define LAN8742_ANER ((uint16_t)0x0006U)
|
||||
#define LAN8742_ANNPTR ((uint16_t)0x0007U)
|
||||
#define LAN8742_ANNPRR ((uint16_t)0x0008U)
|
||||
#define LAN8742_MMDACR ((uint16_t)0x000DU)
|
||||
#define LAN8742_MMDAADR ((uint16_t)0x000EU)
|
||||
#define LAN8742_ENCTR ((uint16_t)0x0010U)
|
||||
#define LAN8742_MCSR ((uint16_t)0x0011U)
|
||||
#define LAN8742_SMR ((uint16_t)0x0012U)
|
||||
#define LAN8742_TPDCR ((uint16_t)0x0018U)
|
||||
#define LAN8742_TCSR ((uint16_t)0x0019U)
|
||||
#define LAN8742_SECR ((uint16_t)0x001AU)
|
||||
#define LAN8742_SCSIR ((uint16_t)0x001BU)
|
||||
#define LAN8742_CLR ((uint16_t)0x001CU)
|
||||
#define LAN8742_ISFR ((uint16_t)0x001DU)
|
||||
#define LAN8742_IMR ((uint16_t)0x001EU)
|
||||
#define LAN8742_PHYSCSR ((uint16_t)0x001FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_BCR_Bit_Definition LAN8742 BCR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_BCR_SOFT_RESET ((uint16_t)0x8000U)
|
||||
#define LAN8742_BCR_LOOPBACK ((uint16_t)0x4000U)
|
||||
#define LAN8742_BCR_SPEED_SELECT ((uint16_t)0x2000U)
|
||||
#define LAN8742_BCR_AUTONEGO_EN ((uint16_t)0x1000U)
|
||||
#define LAN8742_BCR_POWER_DOWN ((uint16_t)0x0800U)
|
||||
#define LAN8742_BCR_ISOLATE ((uint16_t)0x0400U)
|
||||
#define LAN8742_BCR_RESTART_AUTONEGO ((uint16_t)0x0200U)
|
||||
#define LAN8742_BCR_DUPLEX_MODE ((uint16_t)0x0100U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_BSR_Bit_Definition LAN8742 BSR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_BSR_100BASE_T4 ((uint16_t)0x8000U)
|
||||
#define LAN8742_BSR_100BASE_TX_FD ((uint16_t)0x4000U)
|
||||
#define LAN8742_BSR_100BASE_TX_HD ((uint16_t)0x2000U)
|
||||
#define LAN8742_BSR_10BASE_T_FD ((uint16_t)0x1000U)
|
||||
#define LAN8742_BSR_10BASE_T_HD ((uint16_t)0x0800U)
|
||||
#define LAN8742_BSR_100BASE_T2_FD ((uint16_t)0x0400U)
|
||||
#define LAN8742_BSR_100BASE_T2_HD ((uint16_t)0x0200U)
|
||||
#define LAN8742_BSR_EXTENDED_STATUS ((uint16_t)0x0100U)
|
||||
#define LAN8742_BSR_AUTONEGO_CPLT ((uint16_t)0x0020U)
|
||||
#define LAN8742_BSR_REMOTE_FAULT ((uint16_t)0x0010U)
|
||||
#define LAN8742_BSR_AUTONEGO_ABILITY ((uint16_t)0x0008U)
|
||||
#define LAN8742_BSR_LINK_STATUS ((uint16_t)0x0004U)
|
||||
#define LAN8742_BSR_JABBER_DETECT ((uint16_t)0x0002U)
|
||||
#define LAN8742_BSR_EXTENDED_CAP ((uint16_t)0x0001U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_PHYI1R_Bit_Definition LAN8742 PHYI1R Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_PHYI1R_OUI_3_18 ((uint16_t)0xFFFFU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_PHYI2R_Bit_Definition LAN8742 PHYI2R Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_PHYI2R_OUI_19_24 ((uint16_t)0xFC00U)
|
||||
#define LAN8742_PHYI2R_MODEL_NBR ((uint16_t)0x03F0U)
|
||||
#define LAN8742_PHYI2R_REVISION_NBR ((uint16_t)0x000FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ANAR_Bit_Definition LAN8742 ANAR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ANAR_NEXT_PAGE ((uint16_t)0x8000U)
|
||||
#define LAN8742_ANAR_REMOTE_FAULT ((uint16_t)0x2000U)
|
||||
#define LAN8742_ANAR_PAUSE_OPERATION ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ANAR_PO_NOPAUSE ((uint16_t)0x0000U)
|
||||
#define LAN8742_ANAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U)
|
||||
#define LAN8742_ANAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U)
|
||||
#define LAN8742_ANAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ANAR_100BASE_TX_FD ((uint16_t)0x0100U)
|
||||
#define LAN8742_ANAR_100BASE_TX ((uint16_t)0x0080U)
|
||||
#define LAN8742_ANAR_10BASE_T_FD ((uint16_t)0x0040U)
|
||||
#define LAN8742_ANAR_10BASE_T ((uint16_t)0x0020U)
|
||||
#define LAN8742_ANAR_SELECTOR_FIELD ((uint16_t)0x000FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ANLPAR_Bit_Definition LAN8742 ANLPAR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ANLPAR_NEXT_PAGE ((uint16_t)0x8000U)
|
||||
#define LAN8742_ANLPAR_REMOTE_FAULT ((uint16_t)0x2000U)
|
||||
#define LAN8742_ANLPAR_PAUSE_OPERATION ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ANLPAR_PO_NOPAUSE ((uint16_t)0x0000U)
|
||||
#define LAN8742_ANLPAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U)
|
||||
#define LAN8742_ANLPAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U)
|
||||
#define LAN8742_ANLPAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ANLPAR_100BASE_TX_FD ((uint16_t)0x0100U)
|
||||
#define LAN8742_ANLPAR_100BASE_TX ((uint16_t)0x0080U)
|
||||
#define LAN8742_ANLPAR_10BASE_T_FD ((uint16_t)0x0040U)
|
||||
#define LAN8742_ANLPAR_10BASE_T ((uint16_t)0x0020U)
|
||||
#define LAN8742_ANLPAR_SELECTOR_FIELD ((uint16_t)0x000FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ANER_Bit_Definition LAN8742 ANER Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ANER_RX_NP_LOCATION_ABLE ((uint16_t)0x0040U)
|
||||
#define LAN8742_ANER_RX_NP_STORAGE_LOCATION ((uint16_t)0x0020U)
|
||||
#define LAN8742_ANER_PARALLEL_DETECT_FAULT ((uint16_t)0x0010U)
|
||||
#define LAN8742_ANER_LP_NP_ABLE ((uint16_t)0x0008U)
|
||||
#define LAN8742_ANER_NP_ABLE ((uint16_t)0x0004U)
|
||||
#define LAN8742_ANER_PAGE_RECEIVED ((uint16_t)0x0002U)
|
||||
#define LAN8742_ANER_LP_AUTONEG_ABLE ((uint16_t)0x0001U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ANNPTR_Bit_Definition LAN8742 ANNPTR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ANNPTR_NEXT_PAGE ((uint16_t)0x8000U)
|
||||
#define LAN8742_ANNPTR_MESSAGE_PAGE ((uint16_t)0x2000U)
|
||||
#define LAN8742_ANNPTR_ACK2 ((uint16_t)0x1000U)
|
||||
#define LAN8742_ANNPTR_TOGGLE ((uint16_t)0x0800U)
|
||||
#define LAN8742_ANNPTR_MESSAGGE_CODE ((uint16_t)0x07FFU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ANNPRR_Bit_Definition LAN8742 ANNPRR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ANNPTR_NEXT_PAGE ((uint16_t)0x8000U)
|
||||
#define LAN8742_ANNPRR_ACK ((uint16_t)0x4000U)
|
||||
#define LAN8742_ANNPRR_MESSAGE_PAGE ((uint16_t)0x2000U)
|
||||
#define LAN8742_ANNPRR_ACK2 ((uint16_t)0x1000U)
|
||||
#define LAN8742_ANNPRR_TOGGLE ((uint16_t)0x0800U)
|
||||
#define LAN8742_ANNPRR_MESSAGGE_CODE ((uint16_t)0x07FFU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_MMDACR_Bit_Definition LAN8742 MMDACR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_MMDACR_MMD_FUNCTION ((uint16_t)0xC000U)
|
||||
#define LAN8742_MMDACR_MMD_FUNCTION_ADDR ((uint16_t)0x0000U)
|
||||
#define LAN8742_MMDACR_MMD_FUNCTION_DATA ((uint16_t)0x4000U)
|
||||
#define LAN8742_MMDACR_MMD_DEV_ADDR ((uint16_t)0x001FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_ENCTR_Bit_Definition LAN8742 ENCTR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_ENCTR_TX_ENABLE ((uint16_t)0x8000U)
|
||||
#define LAN8742_ENCTR_TX_TIMER ((uint16_t)0x6000U)
|
||||
#define LAN8742_ENCTR_TX_TIMER_1S ((uint16_t)0x0000U)
|
||||
#define LAN8742_ENCTR_TX_TIMER_768MS ((uint16_t)0x2000U)
|
||||
#define LAN8742_ENCTR_TX_TIMER_512MS ((uint16_t)0x4000U)
|
||||
#define LAN8742_ENCTR_TX_TIMER_265MS ((uint16_t)0x6000U)
|
||||
#define LAN8742_ENCTR_RX_ENABLE ((uint16_t)0x1000U)
|
||||
#define LAN8742_ENCTR_RX_MAX_INTERVAL ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ENCTR_RX_MAX_INTERVAL_64MS ((uint16_t)0x0000U)
|
||||
#define LAN8742_ENCTR_RX_MAX_INTERVAL_256MS ((uint16_t)0x0400U)
|
||||
#define LAN8742_ENCTR_RX_MAX_INTERVAL_512MS ((uint16_t)0x0800U)
|
||||
#define LAN8742_ENCTR_RX_MAX_INTERVAL_1S ((uint16_t)0x0C00U)
|
||||
#define LAN8742_ENCTR_EX_CROSS_OVER ((uint16_t)0x0002U)
|
||||
#define LAN8742_ENCTR_EX_MANUAL_CROSS_OVER ((uint16_t)0x0001U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_MCSR_Bit_Definition LAN8742 MCSR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_MCSR_EDPWRDOWN ((uint16_t)0x2000U)
|
||||
#define LAN8742_MCSR_FARLOOPBACK ((uint16_t)0x0200U)
|
||||
#define LAN8742_MCSR_ALTINT ((uint16_t)0x0040U)
|
||||
#define LAN8742_MCSR_ENERGYON ((uint16_t)0x0002U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_SMR_Bit_Definition LAN8742 SMR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_SMR_MODE ((uint16_t)0x00E0U)
|
||||
#define LAN8742_SMR_PHY_ADDR ((uint16_t)0x001FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_TPDCR_Bit_Definition LAN8742 TPDCR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_TPDCR_DELAY_IN ((uint16_t)0x8000U)
|
||||
#define LAN8742_TPDCR_LINE_BREAK_COUNTER ((uint16_t)0x7000U)
|
||||
#define LAN8742_TPDCR_PATTERN_HIGH ((uint16_t)0x0FC0U)
|
||||
#define LAN8742_TPDCR_PATTERN_LOW ((uint16_t)0x003FU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_TCSR_Bit_Definition LAN8742 TCSR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_TCSR_TDR_ENABLE ((uint16_t)0x8000U)
|
||||
#define LAN8742_TCSR_TDR_AD_FILTER_ENABLE ((uint16_t)0x4000U)
|
||||
#define LAN8742_TCSR_TDR_CH_CABLE_TYPE ((uint16_t)0x0600U)
|
||||
#define LAN8742_TCSR_TDR_CH_CABLE_DEFAULT ((uint16_t)0x0000U)
|
||||
#define LAN8742_TCSR_TDR_CH_CABLE_SHORTED ((uint16_t)0x0200U)
|
||||
#define LAN8742_TCSR_TDR_CH_CABLE_OPEN ((uint16_t)0x0400U)
|
||||
#define LAN8742_TCSR_TDR_CH_CABLE_MATCH ((uint16_t)0x0600U)
|
||||
#define LAN8742_TCSR_TDR_CH_STATUS ((uint16_t)0x0100U)
|
||||
#define LAN8742_TCSR_TDR_CH_LENGTH ((uint16_t)0x00FFU)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_SCSIR_Bit_Definition LAN8742 SCSIR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_SCSIR_AUTO_MDIX_ENABLE ((uint16_t)0x8000U)
|
||||
#define LAN8742_SCSIR_CHANNEL_SELECT ((uint16_t)0x2000U)
|
||||
#define LAN8742_SCSIR_SQE_DISABLE ((uint16_t)0x0800U)
|
||||
#define LAN8742_SCSIR_XPOLALITY ((uint16_t)0x0010U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_CLR_Bit_Definition LAN8742 CLR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_CLR_CABLE_LENGTH ((uint16_t)0xF000U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_IMR_ISFR_Bit_Definition LAN8742 IMR ISFR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_INT_8 ((uint16_t)0x0100U)
|
||||
#define LAN8742_INT_7 ((uint16_t)0x0080U)
|
||||
#define LAN8742_INT_6 ((uint16_t)0x0040U)
|
||||
#define LAN8742_INT_5 ((uint16_t)0x0020U)
|
||||
#define LAN8742_INT_4 ((uint16_t)0x0010U)
|
||||
#define LAN8742_INT_3 ((uint16_t)0x0008U)
|
||||
#define LAN8742_INT_2 ((uint16_t)0x0004U)
|
||||
#define LAN8742_INT_1 ((uint16_t)0x0002U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_PHYSCSR_Bit_Definition LAN8742 PHYSCSR Bit Definition
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_PHYSCSR_AUTONEGO_DONE ((uint16_t)0x1000U)
|
||||
#define LAN8742_PHYSCSR_HCDSPEEDMASK ((uint16_t)0x001CU)
|
||||
#define LAN8742_PHYSCSR_10BT_HD ((uint16_t)0x0004U)
|
||||
#define LAN8742_PHYSCSR_10BT_FD ((uint16_t)0x0014U)
|
||||
#define LAN8742_PHYSCSR_100BTX_HD ((uint16_t)0x0008U)
|
||||
#define LAN8742_PHYSCSR_100BTX_FD ((uint16_t)0x0018U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_Status LAN8742 Status
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LAN8742_STATUS_READ_ERROR ((int32_t)-5)
|
||||
#define LAN8742_STATUS_WRITE_ERROR ((int32_t)-4)
|
||||
#define LAN8742_STATUS_ADDRESS_ERROR ((int32_t)-3)
|
||||
#define LAN8742_STATUS_RESET_TIMEOUT ((int32_t)-2)
|
||||
#define LAN8742_STATUS_ERROR ((int32_t)-1)
|
||||
#define LAN8742_STATUS_OK ((int32_t) 0)
|
||||
#define LAN8742_STATUS_LINK_DOWN ((int32_t) 1)
|
||||
#define LAN8742_STATUS_100MBITS_FULLDUPLEX ((int32_t) 2)
|
||||
#define LAN8742_STATUS_100MBITS_HALFDUPLEX ((int32_t) 3)
|
||||
#define LAN8742_STATUS_10MBITS_FULLDUPLEX ((int32_t) 4)
|
||||
#define LAN8742_STATUS_10MBITS_HALFDUPLEX ((int32_t) 5)
|
||||
#define LAN8742_STATUS_AUTONEGO_NOTDONE ((int32_t) 6)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LAN8742_IT_Flags LAN8742 IT Flags
|
||||
* @{
|
||||
*/
|
||||
#define LAN8742_WOL_IT LAN8742_INT_8
|
||||
#define LAN8742_ENERGYON_IT LAN8742_INT_7
|
||||
#define LAN8742_AUTONEGO_COMPLETE_IT LAN8742_INT_6
|
||||
#define LAN8742_REMOTE_FAULT_IT LAN8742_INT_5
|
||||
#define LAN8742_LINK_DOWN_IT LAN8742_INT_4
|
||||
#define LAN8742_AUTONEGO_LP_ACK_IT LAN8742_INT_3
|
||||
#define LAN8742_PARALLEL_DETECTION_FAULT_IT LAN8742_INT_2
|
||||
#define LAN8742_AUTONEGO_PAGE_RECEIVED_IT LAN8742_INT_1
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup LAN8742_Exported_Types LAN8742 Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef int32_t (*lan8742_Init_Func) (void);
|
||||
typedef int32_t (*lan8742_DeInit_Func) (void);
|
||||
typedef int32_t (*lan8742_ReadReg_Func) (uint32_t, uint32_t, uint32_t *);
|
||||
typedef int32_t (*lan8742_WriteReg_Func) (uint32_t, uint32_t, uint32_t);
|
||||
typedef int32_t (*lan8742_GetTick_Func) (void);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lan8742_Init_Func Init;
|
||||
lan8742_DeInit_Func DeInit;
|
||||
lan8742_WriteReg_Func WriteReg;
|
||||
lan8742_ReadReg_Func ReadReg;
|
||||
lan8742_GetTick_Func GetTick;
|
||||
} lan8742_IOCtx_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t DevAddr;
|
||||
uint32_t Is_Initialized;
|
||||
lan8742_IOCtx_t IO;
|
||||
void *pData;
|
||||
}lan8742_Object_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup LAN8742_Exported_Functions LAN8742 Exported Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx);
|
||||
int32_t LAN8742_Init(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_DeInit(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState);
|
||||
int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj);
|
||||
int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt);
|
||||
int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt);
|
||||
int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt);
|
||||
int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LAN8742_H */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
24
bsp_stm32_rtems/boardconfig/led.c
Normal file
24
bsp_stm32_rtems/boardconfig/led.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include "led.h"
|
||||
#include <stm32h743xx.h>
|
||||
#include <stm32h7xx_hal_gpio.h>
|
||||
#include <stm32h7xx_hal_rcc.h>
|
||||
|
||||
/* Configure GPIO pin : PB14 (LD3) */
|
||||
GPIO_InitTypeDef GPIO_InitStruct =
|
||||
{
|
||||
.Pin = GPIO_PIN_14,
|
||||
.Mode = GPIO_MODE_OUTPUT_PP,
|
||||
.Speed = GPIO_SPEED_LOW
|
||||
};
|
||||
|
||||
void ledInit() {
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
void ledOn() {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||
}
|
||||
void ledOff() {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||
}
|
33
bsp_stm32_rtems/boardconfig/led.h
Normal file
33
bsp_stm32_rtems/boardconfig/led.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* LED -- simple LED support
|
||||
*/
|
||||
|
||||
#ifndef __LED_h
|
||||
#define __LED_h
|
||||
|
||||
#include <bspopts.h>
|
||||
|
||||
#if defined(STM32H743xx)
|
||||
/* These settings are for the STM32H743ZI NUCLEO board */
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
extern GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
extern void ledInit();
|
||||
extern void ledOn();
|
||||
extern void ledOff();
|
||||
|
||||
#else
|
||||
/* default case is to print */
|
||||
|
||||
#define __LED_PRINTING 1
|
||||
#define LED_ON() fputs( "LED ON\n", stderr )
|
||||
#define LED_OFF() fputs( "LED OFF\n", stderr )
|
||||
#endif
|
||||
|
||||
#ifndef LED_INIT
|
||||
#define LED_INIT()
|
||||
#endif
|
||||
|
||||
#endif
|
253
bsp_stm32_rtems/boardconfig/lwipopts.h
Normal file
253
bsp_stm32_rtems/boardconfig/lwipopts.h
Normal file
@ -0,0 +1,253 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file LwIP/LwIP_HTTP_Server_Netconn_RTOS/Inc/lwipopts.h
|
||||
* @author MCD Application Team
|
||||
* @brief lwIP Options Configuration.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#define SYS_LIGHTWEIGHT_PROT 0
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 1
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#define MEM_SIZE (10*1024)
|
||||
|
||||
/* Relocate the LwIP RAM heap pointer */
|
||||
#define LWIP_RAM_HEAP_POINTER (0x30044000)
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 10
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 6
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 10
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 5
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 8
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
||||
@ note: used to allocate Tx pbufs only */
|
||||
#define PBUF_POOL_SIZE 4
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 1528
|
||||
|
||||
/* LWIP_SUPPORT_CUSTOM_PBUF == 1: to pass directly MAC Rx buffers to the stack
|
||||
no copy is needed */
|
||||
#define LWIP_SUPPORT_CUSTOM_PBUF 1
|
||||
|
||||
/* ---------- IPv4 options ---------- */
|
||||
#define LWIP_IPV4 1
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 0
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF (4*TCP_MSS)
|
||||
|
||||
/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
|
||||
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
|
||||
|
||||
#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND (2*TCP_MSS)
|
||||
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define LWIP_ICMP 1
|
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
|
||||
/* ---------- link callback options ---------- */
|
||||
/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
|
||||
* whenever the link changes (i.e., link down)
|
||||
*/
|
||||
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||
|
||||
/*
|
||||
--------------------------------------
|
||||
---------- Checksum options ----------
|
||||
--------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
The STM32H7xx allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
|
||||
- To use this feature let the following define uncommented.
|
||||
- To disable it and process by CPU comment the the checksum.
|
||||
*/
|
||||
#define CHECKSUM_BY_HARDWARE
|
||||
|
||||
|
||||
#ifdef CHECKSUM_BY_HARDWARE
|
||||
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 0
|
||||
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 0
|
||||
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 0
|
||||
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 0
|
||||
/* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/
|
||||
#define CHECKSUM_GEN_ICMP 0
|
||||
#else
|
||||
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 1
|
||||
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 1
|
||||
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 1
|
||||
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 1
|
||||
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
/* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/
|
||||
#define CHECKSUM_GEN_ICMP 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------
|
||||
---------- Sequential layer options ----------
|
||||
----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 0
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Socket options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 0
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- httpd options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
|
||||
* file system (to prevent changing the file included in CVS) */
|
||||
#define HTTPD_USE_CUSTOM_FSDATA 1
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- OS options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
#define TCPIP_THREAD_NAME "TCP/IP"
|
||||
#define TCPIP_THREAD_STACKSIZE 1000
|
||||
#define TCPIP_MBOX_SIZE 6
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 6
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 6
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
#define DEFAULT_THREAD_STACKSIZE 500
|
||||
/* Not available on RTEMS */
|
||||
//#define TCPIP_THREAD_PRIO osPriorityHigh
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- ASSERT options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
#define LWIP_NOASSERT
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
79
bsp_stm32_rtems/boardconfig/stm32h7xx_it.c
Normal file
79
bsp_stm32_rtems/boardconfig/stm32h7xx_it.c
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src/stm32h7xx_it.c
|
||||
* @author MCD Application Team
|
||||
* @brief Main Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stm32h7xx_hal.h>
|
||||
#include "stm32h7xx_it.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
extern ETH_HandleTypeDef EthHandle;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void ETH_IRQHandler(void);
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M7 Processor Exceptions Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32H7xx Peripherals Interrupt Handlers */
|
||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
||||
/* available peripheral interrupt handler's name please refer to the startup */
|
||||
/* file (startup_stm32h7xx.s). */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Ethernet interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void ETH_IRQHandler(void)
|
||||
{
|
||||
HAL_ETH_IRQHandler(&EthHandle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
40
bsp_stm32_rtems/boardconfig/stm32h7xx_it.h
Normal file
40
bsp_stm32_rtems/boardconfig/stm32h7xx_it.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Templates/Inc/stm32h7xx_it.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32H7xx_IT_H
|
||||
#define __STM32H7xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32H7xx_IT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
694
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo.c
Normal file
694
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo.c
Normal file
@ -0,0 +1,694 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h7xx_nucleo.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides set of firmware functions to manage:
|
||||
* - LEDs and push-button available on STM32H7xx-Nucleo Kit
|
||||
* from STMicroelectronics
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2018 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_nucleo.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H7XX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H7XX_NUCLEO_LOW_LEVEL
|
||||
* @brief This file provides set of firmware functions to manage Leds and push-button
|
||||
* available on STM32H7xx-Nucleo Kit from STMicroelectronics.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Defines LOW LEVEL Private Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions LOW LEVEL Private Typedef
|
||||
* @{
|
||||
*/
|
||||
typedef void (* BSP_EXTI_LineCallback) (void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported Variables
|
||||
* @{
|
||||
*/
|
||||
EXTI_HandleTypeDef hpb_exti[BUTTONn];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
UART_HandleTypeDef hcom_uart[COMn];
|
||||
USART_TypeDef* COM_USART[COMn] = {COM1_UART};
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Variables LOW LEVEL Private Variables
|
||||
* @{
|
||||
*/
|
||||
static GPIO_TypeDef* LED_PORT[LEDn] = {LED1_GPIO_PORT,
|
||||
LED2_GPIO_PORT,
|
||||
LED3_GPIO_PORT};
|
||||
|
||||
static const uint16_t LED_PIN[LEDn] = {LED1_PIN,
|
||||
LED2_PIN,
|
||||
LED3_PIN};
|
||||
|
||||
static GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {BUTTON_USER_GPIO_PORT};
|
||||
static const uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_USER_PIN};
|
||||
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
|
||||
|
||||
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
#if (USE_COM_LOG > 0)
|
||||
static COM_TypeDef COM_ActiveLogPort = COM1;
|
||||
#endif
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
static uint32_t IsComMspCbValid[COMn] = {0};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_FunctionPrototypes LOW LEVEL Private functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void BUTTON_USER_EXTI_Callback(void);
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
static void COM1_MspInit(UART_HandleTypeDef *huart);
|
||||
static void COM1_MspDeInit(UART_HandleTypeDef *huart);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This method returns the STM32H7XX NUCLEO BSP Driver revision
|
||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
||||
*/
|
||||
int32_t BSP_GetVersion(void)
|
||||
{
|
||||
return (int32_t)STM32H7XX_NUCLEO_BSP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures LED GPIO.
|
||||
* @param Led Specifies the Led to be configured.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable the GPIO LED Clock */
|
||||
if(Led == LED1)
|
||||
{
|
||||
LED1_GPIO_CLK_ENABLE();
|
||||
}
|
||||
else if(Led == LED2)
|
||||
{
|
||||
LED2_GPIO_CLK_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
LED3_GPIO_CLK_ENABLE();
|
||||
}
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = LED_PIN[Led];
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
||||
HAL_GPIO_Init(LED_PORT[Led], &gpio_init_structure);
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit LEDs.
|
||||
* @param Led LED to be de-init.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @note Led DeInit does not disable the GPIO clock nor disable the Mfx
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn off LED */
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
/* DeInit the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = LED_PIN[Led];
|
||||
HAL_GPIO_DeInit(LED_PORT[Led], gpio_init_structure.Pin);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED On.
|
||||
* @param Led Specifies the Led to be set on.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_On(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED Off.
|
||||
* @param Led: Specifies the Led to be set off.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected LED.
|
||||
* @param Led Specifies the Led to be toggled.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the state of the selected LED.
|
||||
* @param Led LED to get its state
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @arg LED3
|
||||
* @retval LED status
|
||||
*/
|
||||
int32_t BSP_LED_GetState (Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (int32_t)HAL_GPIO_ReadPin (LED_PORT [Led], LED_PIN [Led]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures button GPIO and EXTI Line.
|
||||
* @param Button Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: Wakeup Push Button
|
||||
* @param ButtonMode Button mode
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO
|
||||
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
|
||||
* with interrupt generation capability
|
||||
*/
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {BUTTON_USER_EXTI_Callback};
|
||||
static uint32_t BSP_BUTTON_PRIO [BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
|
||||
static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE};
|
||||
|
||||
/* Enable the BUTTON clock */
|
||||
BUTTON_USER_GPIO_CLK_ENABLE();
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN [Button];
|
||||
gpio_init_structure.Pull = GPIO_PULLDOWN;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_GPIO)
|
||||
{
|
||||
/* Configure Button pin as input */
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
HAL_GPIO_Init(BUTTON_PORT [Button], &gpio_init_structure);
|
||||
}
|
||||
else /* (ButtonMode == BUTTON_MODE_EXTI) */
|
||||
{
|
||||
/* Configure Button pin as input with External interrupt */
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
||||
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
|
||||
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);
|
||||
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, ButtonCallback[Button]);
|
||||
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), BSP_BUTTON_PRIO[Button], 0x00);
|
||||
HAL_NVIC_EnableIRQ((BUTTON_IRQn[Button]));
|
||||
}
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Push Button DeInit.
|
||||
* @param Button Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: Wakeup Push Button
|
||||
* @note PB DeInit does not disable the GPIO clock
|
||||
*/
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the selected button state.
|
||||
* @param Button Button to be checked
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: Wakeup Push Button
|
||||
* @retval The Button GPIO pin value (GPIO_PIN_RESET = button pressed)
|
||||
*/
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button)
|
||||
{
|
||||
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Button IRQ handler
|
||||
* @param Button Can only be BUTTON_USER
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button)
|
||||
{
|
||||
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Push Button callback
|
||||
* @param Button Specifies the pin connected EXTI line
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_PB_Callback(Button_TypeDef Button)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Button);
|
||||
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when an event on Button is triggered. */
|
||||
}
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval BSP error code
|
||||
*/
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
/* Init the UART Msp */
|
||||
COM1_MspInit(&hcom_uart[COM]);
|
||||
#else
|
||||
if(IsComMspCbValid[COM] == 0U)
|
||||
{
|
||||
if(BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
|
||||
{
|
||||
return BSP_ERROR_MSP_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(MX_USART3_Init(&hcom_uart[COM], COM_Init) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* USART configuration */
|
||||
hcom_uart[COM].Instance = COM_USART[COM];
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
COM1_MspDeInit(&hcom_uart[COM]);
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
|
||||
|
||||
if(HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param huart USART handle
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval HAL error code
|
||||
*/
|
||||
__weak HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init)
|
||||
{
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM1];
|
||||
huart->Init.BaudRate = COM_Init->BaudRate;
|
||||
huart->Init.Mode = UART_MODE_TX_RX;
|
||||
huart->Init.Parity = (uint32_t)COM_Init->Parity;
|
||||
huart->Init.WordLength = (uint32_t)COM_Init->WordLength;
|
||||
huart->Init.StopBits = (uint32_t)COM_Init->StopBits;
|
||||
huart->Init.HwFlowCtl = (uint32_t)COM_Init->HwFlowCtl;
|
||||
huart->Init.OverSampling = UART_OVERSAMPLING_8;
|
||||
|
||||
return HAL_UART_Init(huart);
|
||||
}
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief Register Default COM Msp Callbacks
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register default MspInit/MspDeInit Callback */
|
||||
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, COM1_MspInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, COM1_MspDeInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register COM Msp Callback registering
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if(COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, Callback->pMspInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
#if (USE_COM_LOG > 0)
|
||||
/**
|
||||
* @brief Select the active COM port.
|
||||
* @param COM COM port to be activated.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
|
||||
{
|
||||
if(COM_ActiveLogPort != COM)
|
||||
{
|
||||
COM_ActiveLogPort = COM;
|
||||
}
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Redirect console output to COM
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
int __io_putchar (int ch)
|
||||
#else
|
||||
int fputc (int ch, FILE *f)
|
||||
#endif /* __GNUC__ */
|
||||
{
|
||||
HAL_UART_Transmit (&hcom_uart [COM_ActiveLogPort], (uint8_t *) &ch, 1, COM_POLL_TIMEOUT);
|
||||
return ch;
|
||||
}
|
||||
#endif /* USE_COM_LOG */
|
||||
#endif /* USE_BSP_COM_FEATURE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Functions LOW LEVEL Private functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Key EXTI line detection callbacks.
|
||||
* @retval BSP status
|
||||
*/
|
||||
static void BUTTON_USER_EXTI_Callback(void)
|
||||
{
|
||||
BSP_PB_Callback(BUTTON_USER);
|
||||
}
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/**
|
||||
* @brief Initializes UART MSP.
|
||||
* @param huart UART handle
|
||||
* @retval BSP status
|
||||
*/
|
||||
static void COM1_MspInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* Enable GPIO clock */
|
||||
COM1_TX_GPIO_CLK_ENABLE();
|
||||
COM1_RX_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Enable USART clock */
|
||||
COM1_CLK_ENABLE();
|
||||
|
||||
/* Configure USART Tx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Alternate = COM1_TX_AF;
|
||||
HAL_GPIO_Init(COM1_TX_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure USART Rx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = COM1_RX_AF;
|
||||
HAL_GPIO_Init(COM1_RX_GPIO_PORT, &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize USART3 Msp part
|
||||
* @param huart UART handle
|
||||
* @retval BSP status
|
||||
*/
|
||||
static void COM1_MspDeInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* COM GPIO pin configuration */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_TX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_RX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
/* Disable USART clock */
|
||||
COM1_CLK_DISABLE();
|
||||
}
|
||||
#endif /* USE_BSP_COM_FEATURE */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
338
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo.h
Normal file
338
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo.h
Normal file
@ -0,0 +1,338 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h7xx_nucleo.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for:
|
||||
* - LEDs and push-button available on STM32H7xx-Nucleo Kit
|
||||
* from STMicroelectronics
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H7XX_NUCLEO_H
|
||||
#define STM32H7XX_NUCLEO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_nucleo_conf.h"
|
||||
#include "stm32h7xx_nucleo_errno.h"
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
#if (USE_COM_LOG > 0)
|
||||
#ifndef __GNUC__
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO STM32H7XX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define for STM32H7XX_NUCLEO board
|
||||
*/
|
||||
#if !defined (USE_STM32H7XX_NUCLEO)
|
||||
#define USE_STM32H7XX_NUCLEO
|
||||
#endif
|
||||
|
||||
#if !defined (USE_NUCLEO_144)
|
||||
#error "Board Pin number not defined!! Add USE_NUCLEO_144 define within stm32h7xx_nucleo_conf.h file"
|
||||
#endif
|
||||
|
||||
#if !defined (USE_NUCLEO_H745ZI_Q) && !defined (USE_NUCLEO_H743ZI) && !defined (USE_NUCLEO_H743ZI2) &&\
|
||||
!defined (USE_NUCLEO_H7A3ZI_Q) && !defined (USE_NUCLEO_H723ZG)
|
||||
#error "Board Part number not defined!! Add one of the following define within stm32h7xx_nucleo_conf.h file:\
|
||||
USE_NUCLEO_H745ZI_Q, USE_NUCLEO_H743ZI, USE_NUCLEO_H743ZI2, USE_NUCLEO_H7A3ZI_Q, USE_NUCLEO_H723ZG"
|
||||
#endif
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
#if defined (USE_NUCLEO_H745ZI_Q) || defined (USE_NUCLEO_H743ZI2) || defined (USE_NUCLEO_H7A3ZI_Q) || defined (USE_NUCLEO_H723ZG)
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED_GREEN = LED1,
|
||||
LED2 = 1,
|
||||
LED_YELLOW = LED2,
|
||||
LED3 = 2,
|
||||
LED_RED = LED3,
|
||||
LEDn
|
||||
}Led_TypeDef;
|
||||
#else /* USE_NUCLEO_H743ZI */
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED_GREEN = LED1,
|
||||
LED2 = 1,
|
||||
LED_BLUE = LED2,
|
||||
LED3 = 2,
|
||||
LED_RED = LED3,
|
||||
LEDn
|
||||
}Led_TypeDef;
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_USER = 0U,
|
||||
BUTTONn
|
||||
}Button_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0,
|
||||
BUTTON_MODE_EXTI = 1
|
||||
}ButtonMode_TypeDef;
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0U,
|
||||
COMn
|
||||
}COM_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_STOPBITS_1 = UART_STOPBITS_1,
|
||||
COM_STOPBITS_2 = UART_STOPBITS_2,
|
||||
}COM_StopBitsTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_PARITY_NONE = UART_PARITY_NONE,
|
||||
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
||||
COM_PARITY_ODD = UART_PARITY_ODD,
|
||||
}COM_ParityTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
||||
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
||||
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
||||
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
|
||||
}COM_HwFlowCtlTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_WORDLENGTH_7B = UART_WORDLENGTH_7B,
|
||||
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
||||
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
||||
}COM_WordLengthTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate;
|
||||
COM_WordLengthTypeDef WordLength;
|
||||
COM_StopBitsTypeDef StopBits;
|
||||
COM_ParityTypeDef Parity;
|
||||
COM_HwFlowCtlTypeDef HwFlowCtl;
|
||||
}COM_InitTypeDef;
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
void (* pMspInitCb)(UART_HandleTypeDef *);
|
||||
void (* pMspDeInitCb)(UART_HandleTypeDef *);
|
||||
}BSP_COM_Cb_t;
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
#define MX_UART_InitTypeDef COM_InitTypeDef
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STM32H7XX NUCLEO BSP Driver version number V1.1.0
|
||||
*/
|
||||
#define STM32H7XX_NUCLEO_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
||||
#define STM32H7XX_NUCLEO_BSP_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */
|
||||
#define STM32H7XX_NUCLEO_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
|
||||
#define STM32H7XX_NUCLEO_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
||||
#define STM32H7XX_NUCLEO_BSP_VERSION ((STM32H7XX_NUCLEO_BSP_VERSION_MAIN << 24)\
|
||||
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|
||||
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|
||||
|(STM32H7XX_NUCLEO_BSP_VERSION_RC))
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_LED LOW LEVEL LED
|
||||
* @{
|
||||
*/
|
||||
#define LEDn 3U
|
||||
|
||||
#define LED1_PIN GPIO_PIN_0
|
||||
#define LED1_GPIO_PORT GPIOB
|
||||
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#if defined (USE_NUCLEO_H745ZI_Q) || defined (USE_NUCLEO_H743ZI2) || defined (USE_NUCLEO_H7A3ZI_Q) || defined (USE_NUCLEO_H723ZG)
|
||||
#define LED2_PIN GPIO_PIN_1
|
||||
#define LED2_GPIO_PORT GPIOE
|
||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
|
||||
#else /* USE_NUCLEO_H743ZI */
|
||||
#define LED2_PIN GPIO_PIN_7
|
||||
#define LED2_GPIO_PORT GPIOB
|
||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#endif
|
||||
|
||||
#define LED3_PIN GPIO_PIN_14
|
||||
#define LED3_GPIO_PORT GPIOB
|
||||
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_BUTTON LOW LEVEL BUTTON
|
||||
* @{
|
||||
*/
|
||||
/* Button state */
|
||||
#define BUTTON_RELEASED 0U
|
||||
#define BUTTON_PRESSED 1U
|
||||
#define BUTTONn 1U
|
||||
|
||||
/**
|
||||
* @brief Key push-button
|
||||
*/
|
||||
#define BUTTON_USER_PIN GPIO_PIN_13
|
||||
#define BUTTON_USER_GPIO_PORT GPIOC
|
||||
#define BUTTON_USER_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define BUTTON_USER_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define BUTTON_USER_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define BUTTON_USER_EXTI_LINE EXTI_LINE_13
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_COM LOW LEVEL COM
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Definition for COM port1, connected to USART3
|
||||
*/
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
|
||||
#define COMn 1U
|
||||
#define COM1_UART USART3
|
||||
#define COM1_CLK_ENABLE() __HAL_RCC_USART3_CLK_ENABLE()
|
||||
#define COM1_CLK_DISABLE() __HAL_RCC_USART3_CLK_DISABLE()
|
||||
|
||||
#define COM1_TX_PIN GPIO_PIN_8
|
||||
#define COM1_TX_GPIO_PORT GPIOD
|
||||
#define COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
#define COM1_TX_AF GPIO_AF7_USART3
|
||||
|
||||
#define COM1_RX_PIN GPIO_PIN_9
|
||||
#define COM1_RX_GPIO_PORT GPIOD
|
||||
#define COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
#define COM1_RX_AF GPIO_AF7_USART3
|
||||
#define COM_POLL_TIMEOUT 1000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern EXTI_HandleTypeDef hpb_exti[];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
extern UART_HandleTypeDef hcom_uart[];
|
||||
extern USART_TypeDef* COM_USART[];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_FunctionsPrototypes LOW LEVEL Exported Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_GetVersion(void);
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led);
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led);
|
||||
int32_t BSP_LED_On(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led);
|
||||
int32_t BSP_LED_GetState (Led_TypeDef Led);
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button);
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button);
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button);
|
||||
void BSP_PB_Callback(Button_TypeDef Button);
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init);
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM);
|
||||
#if (USE_COM_LOG > 0)
|
||||
int32_t BSP_COM_SelectLogPort (COM_TypeDef COM);
|
||||
#endif
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback);
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init);
|
||||
#endif /* USE_BSP_COM_FEATURE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H7XX_NUCLEO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
82
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo_conf.h
Normal file
82
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo_conf.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h7xx_nucleo_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief STM32H7xx_Nuleo board configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H7XX_NUCLEO_CONF_H
|
||||
#define STM32H7XX_NUCLEO_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_hal.h"
|
||||
#include "stm32h743xx.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H7XX_NUCLEO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_CONFIG Config
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H7XX_NUCLEO_CONFIG_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* Nucleo pin and part number defines */
|
||||
#define USE_NUCLEO_144
|
||||
#define USE_NUCLEO_H743ZI
|
||||
|
||||
/* COM define */
|
||||
#define USE_COM_LOG 0U
|
||||
#define USE_BSP_COM_FEATURE 1U
|
||||
|
||||
/* IRQ priorities */
|
||||
#define BSP_BUTTON_USER_IT_PRIORITY 15U
|
||||
|
||||
#define BUS_SPI1_BAUDRATE 18000000
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H7XX_NUCLEO_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
48
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo_errno.h
Normal file
48
bsp_stm32_rtems/boardconfig/stm32h7xx_nucleo_errno.h
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h7xx_nucleo_errno.h
|
||||
* @author MCD Application Team
|
||||
* @brief Error Code.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H7XX_NUCLEO_ERRNO_H
|
||||
#define STM32H7XX_NUCLEO_ERRNO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Common Error codes */
|
||||
#define BSP_ERROR_NONE 0
|
||||
#define BSP_ERROR_NO_INIT -1
|
||||
#define BSP_ERROR_WRONG_PARAM -2
|
||||
#define BSP_ERROR_BUSY -3
|
||||
#define BSP_ERROR_PERIPH_FAILURE -4
|
||||
#define BSP_ERROR_COMPONENT_FAILURE -5
|
||||
#define BSP_ERROR_UNKNOWN_FAILURE -6
|
||||
#define BSP_ERROR_UNKNOWN_COMPONENT -7
|
||||
#define BSP_ERROR_BUS_FAILURE -8
|
||||
#define BSP_ERROR_CLOCK_FAILURE -9
|
||||
#define BSP_ERROR_MSP_FAILURE -10
|
||||
#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H7XX_NUCLEO_ERRNO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
2
bsp_stm32_rtems/boardtest/CMakeLists.txt
Normal file
2
bsp_stm32_rtems/boardtest/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
)
|
6
bsp_stm32_rtems/core/CMakeLists.txt
Normal file
6
bsp_stm32_rtems/core/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
InitMission.cpp
|
||||
ObjectFactory.cpp
|
||||
printChar.c
|
||||
)
|
||||
|
196
bsp_stm32_rtems/core/InitMission.cpp
Normal file
196
bsp_stm32_rtems/core/InitMission.cpp
Normal file
@ -0,0 +1,196 @@
|
||||
#include "InitMission.h"
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
#include <mission/utility/TaskCreation.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
#include <pollingsequence/pollingSequenceFactory.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/score/heapinfo.h>
|
||||
|
||||
|
||||
void InitMission::createTasks() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* distributerTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"DIST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR);
|
||||
}
|
||||
result = distributerTask->addComponent(objects::PUS_DISTRIBUTOR);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS distributor", objects::CCSDS_DISTRIBUTOR);
|
||||
}
|
||||
result = distributerTask->addComponent(objects::TM_FUNNEL);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("TM funnel", objects::TM_FUNNEL);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* eventManagerTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"EVENT_MGMT", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.1, nullptr);
|
||||
result = eventManagerTask->addComponent(objects::EVENT_MANAGER);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("TM funnel", objects::TM_FUNNEL);
|
||||
}
|
||||
|
||||
#if OBSW_ADD_LWIP_NETWORKING == 1
|
||||
/* UDP bridge */
|
||||
PeriodicTaskIF* udpBridgeTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = udpBridgeTask->addComponent(objects::UDP_BRIDGE);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("UDP bridge", objects::UDP_BRIDGE);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* udpPollingTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"UDP_POLLING", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.1, nullptr);
|
||||
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("UDP polling task", objects::UDP_POLLING_TASK);
|
||||
}
|
||||
#endif /* OBSW_ADD_LWIP_NETWORKING == 1 */
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
#if OBSW_ADD_PUS_STACK == 1
|
||||
/* PUS Services */
|
||||
PeriodicTaskIF* pusVerification = TaskFactory::instance()->createPeriodicTask(
|
||||
"PUS_VERIF_1", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
|
||||
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
task::printInitError("PUS 1", objects::PUS_SERVICE_1_VERIFICATION);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusHighPrio = TaskFactory::instance()->createPeriodicTask(
|
||||
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
}
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
task::printInitError("PUS 5", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
}
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 9", objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusMedPrio = TaskFactory::instance()->createPeriodicTask(
|
||||
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, nullptr);
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
}
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 200", objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusLowPrio = TaskFactory::instance()->createPeriodicTask(
|
||||
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, nullptr);
|
||||
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
task::printInitError("PUS 17", objects::PUS_SERVICE_17_TEST);
|
||||
}
|
||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||
|
||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||
FixedTimeslotTaskIF* timeslotDemoTask = TaskFactory::instance()->createFixedTimeslotTask(
|
||||
"PST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, nullptr);
|
||||
result = pst::pollingSequenceExamples(timeslotDemoTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "InitMission::createTasks: Examples PST initialization failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("InitMission::createTasks: Examples PST initialization failed!\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
PeriodicTaskIF* readerTask = TaskFactory::instance()->
|
||||
createPeriodicTask("READER_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = readerTask->addComponent(objects::TEST_DUMMY_4);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("Demo Reader Task", objects::TEST_DUMMY_4);
|
||||
}
|
||||
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
FixedTimeslotTaskIF* testTimeslotTask = TaskFactory::instance()->createFixedTimeslotTask(
|
||||
"PST_TEST_TASK", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = pst::pollingSequenceDevices(testTimeslotTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "InitMission::createTasks: Devices PST initialization failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("InitMission::createTasks: Devices PST initialization failed!\n");
|
||||
#endif
|
||||
}
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
PeriodicTaskIF* testTask = TaskFactory::instance()->
|
||||
createPeriodicTask("TEST", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = testTask->addComponent(objects::TEST_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("Test Task", objects::TEST_TASK);
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Starting tasks.." << std::endl;
|
||||
#else
|
||||
sif::printInfo("Starting tasks..\n");
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
distributerTask->startTask();
|
||||
eventManagerTask->startTask();
|
||||
#if OBSW_ADD_LWIP_NETWORKING == 1
|
||||
udpBridgeTask->startTask();
|
||||
udpPollingTask->startTask();
|
||||
#endif /* OBSW_ADD_LWIP_NETWORKING == 1 */
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
#if OBSW_ADD_PUS_STACK == 1
|
||||
pusVerification->startTask();
|
||||
pusHighPrio->startTask();
|
||||
pusMedPrio->startTask();
|
||||
pusLowPrio->startTask();
|
||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||
|
||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||
timeslotDemoTask->startTask();
|
||||
readerTask->startTask();
|
||||
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
testTimeslotTask->startTask();
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
testTask->startTask();
|
||||
|
||||
Heap_Information_block block;
|
||||
rtems_workspace_get_information(&block);
|
||||
uint32_t failedAllocs = block.Stats.failed_allocs;
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Tasks started.." << std::endl;
|
||||
sif::info << "Remaining RTEMS heap: " << block.Stats.free_size << " bytes" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Tasks started..\n");
|
||||
sif::printInfo("Allocated RTEMS heap: %lu bytes\n", static_cast<unsigned long>(
|
||||
block.Stats.size));
|
||||
sif::printInfo("Remaining RTEMS heap: %lu bytes\n", static_cast<unsigned long>(
|
||||
block.Stats.free_size));
|
||||
if(failedAllocs > 0) {
|
||||
sif::printWarning("%d allocations from RTEMS workspace failed!\n", failedAllocs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
8
bsp_stm32_rtems/core/InitMission.h
Normal file
8
bsp_stm32_rtems/core/InitMission.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef MISSION_CORE_INITMISSION_H_
|
||||
#define MISSION_CORE_INITMISSION_H_
|
||||
|
||||
namespace InitMission {
|
||||
void createTasks();
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_INITMISSION_H_ */
|
58
bsp_stm32_rtems/core/ObjectFactory.cpp
Normal file
58
bsp_stm32_rtems/core/ObjectFactory.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "ObjectFactory.h"
|
||||
#include <OBSWConfig.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
|
||||
#include <common/stm32_nucleo/networking/UdpTcLwIpPollingTask.h>
|
||||
#include <common/stm32_nucleo/networking/TmTcLwIpUdpBridge.h>
|
||||
#include <common/stm32_nucleo/STM32TestTask.h>
|
||||
#include <test/TestTask.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <mission/core/GenericFactory.h>
|
||||
|
||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <fsfw/monitoring/MonitoringMessageContent.h>
|
||||
#include <fsfw/storagemanager/PoolManager.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
|
||||
void ObjectFactory::produce() {
|
||||
/* Located inside GenericFactory source file */
|
||||
Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
|
||||
};
|
||||
new PoolManager(objects::TC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
|
||||
};
|
||||
new PoolManager(objects::TM_STORE, poolCfg);
|
||||
}
|
||||
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
|
||||
};
|
||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
|
||||
#if OBSW_ADD_LWIP_NETWORKING == 1
|
||||
/* UDP Server */
|
||||
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE,
|
||||
objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE);
|
||||
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
||||
#endif /* OBSW_ADD_LWIP_NETWORKING == 1 */
|
||||
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
ObjectFactory::produceGenericObjects();
|
||||
|
||||
new STM32TestTask(objects::TEST_TASK, false);
|
||||
}
|
9
bsp_stm32_rtems/core/ObjectFactory.h
Normal file
9
bsp_stm32_rtems/core/ObjectFactory.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef MISSION_CORE_OBJECTFACTORY_H_
|
||||
#define MISSION_CORE_OBJECTFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void produce();
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */
|
17
bsp_stm32_rtems/core/printChar.c
Normal file
17
bsp_stm32_rtems/core/printChar.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <OBSWConfig.h>
|
||||
#include <stm32h7xx_hal_uart.h>
|
||||
#include <hardware_init.h>
|
||||
|
||||
#include <hal.h>
|
||||
|
||||
void printChar(const char* character, bool errStream) {
|
||||
HAL_UART_Transmit(&stm32h7_usart3_instance.uart, (uint8_t*) character, 1,
|
||||
DEBUG_UART_MS_TIMEOUT);
|
||||
/* Does not work for some reason */
|
||||
//stm32h7_uart_polled_write(&stm32h7_usart3_instance.device, (int) character);
|
||||
}
|
||||
|
||||
|
||||
|
14
bsp_stm32_rtems/fsfwconfig/CMakeLists.txt
Normal file
14
bsp_stm32_rtems/fsfwconfig/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
ipc/missionMessageTypes.cpp
|
||||
pollingsequence/pollingSequenceFactory.cpp
|
||||
)
|
||||
|
||||
# Add include paths for the executable
|
||||
target_include_directories(${TARGET_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if(NOT DEFINED FSFW_CONFIG_DIRECTORY)
|
||||
set(FSFW_CONFIG_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
72
bsp_stm32_rtems/fsfwconfig/FSFWConfig.h
Normal file
72
bsp_stm32_rtems/fsfwconfig/FSFWConfig.h
Normal file
@ -0,0 +1,72 @@
|
||||
#ifndef CONFIG_FSFWCONFIG_H_
|
||||
#define CONFIG_FSFWCONFIG_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
//! Used to determine whether C++ ostreams are used which can increase
|
||||
//! the binary size significantly. If this is disabled,
|
||||
//! the C stdio functions can be used alternatively
|
||||
#define FSFW_CPP_OSTREAM_ENABLED 0
|
||||
|
||||
//! More FSFW related printouts depending on level. Useful for development.
|
||||
#define FSFW_VERBOSE_LEVEL 1
|
||||
|
||||
//! Can be used to completely disable printouts, even the C stdio ones.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0
|
||||
#define FSFW_DISABLE_PRINTOUT 0
|
||||
#endif
|
||||
|
||||
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||
|
||||
//! Can be used to disable the ANSI color sequences for C stdio.
|
||||
#define FSFW_COLORED_OUTPUT 1
|
||||
|
||||
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
|
||||
//! additional output which requires the translation files translateObjects
|
||||
//! and translateEvents (and their compiled source files)
|
||||
#define FSFW_OBJ_EVENT_TRANSLATION 0
|
||||
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
//! Specify whether info events are printed too.
|
||||
#define FSFW_DEBUG_INFO 1
|
||||
#include "objects/translateObjects.h"
|
||||
#include "events/translateEvents.h"
|
||||
#else
|
||||
#endif
|
||||
|
||||
//! When using the newlib nano library, C99 support for stdio facilities
|
||||
//! will not be provided. This define should be set to 1 if this is the case.
|
||||
#define FSFW_NO_C99_IO 1
|
||||
|
||||
//! Specify whether a special mode store is used for Subsystem components.
|
||||
#define FSFW_USE_MODESTORE 0
|
||||
|
||||
//! Defines if the real time scheduler for linux should be used.
|
||||
//! If set to 0, this will also disable priority settings for linux
|
||||
//! as most systems will not allow to set nice values without privileges
|
||||
//! For embedded linux system set this to 1.
|
||||
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
|
||||
#define FSFW_USE_REALTIME_FOR_LINUX 0
|
||||
|
||||
namespace fsfwconfig {
|
||||
|
||||
//! Default timestamp size. The default timestamp will be an seven byte CDC short timestamp.
|
||||
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 7;
|
||||
|
||||
//! Configure the allocated pool sizes for the event manager.
|
||||
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
|
||||
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
|
||||
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
|
||||
|
||||
//! Defines the FIFO depth of each commanding service base which
|
||||
//! also determines how many commands a CSB service can handle in one cycle
|
||||
//! simultaneously. This will increase the required RAM for
|
||||
//! each CSB service !
|
||||
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
||||
|
||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
39
bsp_stm32_rtems/fsfwconfig/OBSWConfig.h
Normal file
39
bsp_stm32_rtems/fsfwconfig/OBSWConfig.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @brief This file can be used to add preprocessor define for conditional
|
||||
* code inclusion exclusion or various other project constants and
|
||||
* properties in one place.
|
||||
*/
|
||||
#ifndef FSFWCONFIG_OBSWCONFIG_H_
|
||||
#define FSFWCONFIG_OBSWCONFIG_H_
|
||||
|
||||
#define DEBUG_UART_MS_TIMEOUT 10
|
||||
|
||||
#define OBSW_ADD_LWIP_NETWORKING 1
|
||||
//! Only applies if TMTC commanding is enabled.
|
||||
//! Specify whether LEDs are used to display Ethernet connection status.
|
||||
#define OBSW_ETHERNET_USE_LED1_LED2 0
|
||||
|
||||
#define OBSW_ATTEMPT_DHCP_CONN 1
|
||||
|
||||
#if OBSW_ATTEMPT_DHCP_CONN == 0
|
||||
#define MAX_DHCP_TRIES 0
|
||||
#else
|
||||
#define MAX_DHCP_TRIES 3
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include <commonConfig.h>
|
||||
|
||||
namespace config {
|
||||
#endif
|
||||
|
||||
/* Add mission configuration flags here */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FSFWCONFIG_OBSWCONFIG_H_ */
|
18
bsp_stm32_rtems/fsfwconfig/events/subsystemIdRanges.h
Normal file
18
bsp_stm32_rtems/fsfwconfig/events/subsystemIdRanges.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
|
||||
#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <fsfw/events/fwSubsystemIdRanges.h>
|
||||
|
||||
/**
|
||||
* @brief Custom subsystem IDs can be added here
|
||||
* @details
|
||||
* Subsystem IDs are used to create unique events.
|
||||
*/
|
||||
namespace SUBSYSTEM_ID {
|
||||
enum: uint8_t {
|
||||
SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE,
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */
|
15
bsp_stm32_rtems/fsfwconfig/fsfwconfig.mk
Normal file
15
bsp_stm32_rtems/fsfwconfig/fsfwconfig.mk
Normal file
@ -0,0 +1,15 @@
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/tmtc/*.cpp)
|
||||
CXXSRC += $(wildcard $(CURRENTPATH)/devices/*.cpp)
|
||||
|
||||
INCLUDES += $(CURRENTPATH)
|
||||
INCLUDES += $(CURRENTPATH)/objects
|
||||
INCLUDES += $(CURRENTPATH)/returnvalues
|
||||
INCLUDES += $(CURRENTPATH)/tmtc
|
||||
INCLUDES += $(CURRENTPATH)/events
|
||||
INCLUDES += $(CURRENTPATH)/devices
|
||||
INCLUDES += $(CURRENTPATH)/pollingsequence
|
||||
INCLUDES += $(CURRENTPATH)/ipc
|
11
bsp_stm32_rtems/fsfwconfig/ipc/missionMessageTypes.cpp
Normal file
11
bsp_stm32_rtems/fsfwconfig/ipc/missionMessageTypes.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "missionMessageTypes.h"
|
||||
#include <fsfw/ipc/CommandMessage.h>
|
||||
#include <fsfw/ipc/CommandMessageCleaner.h>
|
||||
|
||||
void messagetypes::clearMissionMessage(CommandMessage* message) {
|
||||
switch((message->getMessageType())) {
|
||||
default:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
19
bsp_stm32_rtems/fsfwconfig/ipc/missionMessageTypes.h
Normal file
19
bsp_stm32_rtems/fsfwconfig/ipc/missionMessageTypes.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_
|
||||
#define FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_
|
||||
|
||||
#include <fsfw/ipc/FwMessageTypes.h>
|
||||
|
||||
class CommandMessage;
|
||||
|
||||
namespace messagetypes {
|
||||
/* First type must have number MESSAGE_TYPE::FW_MESSAGES_COUNT! */
|
||||
/* Remember to add new message types to the clearMissionMessage function below! */
|
||||
enum MISSION_MESSAGE_TYPE {
|
||||
COSTUM_MESSAGE = FW_MESSAGES_COUNT,
|
||||
};
|
||||
|
||||
void clearMissionMessage(CommandMessage* message);
|
||||
|
||||
}
|
||||
|
||||
#endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */
|
16
bsp_stm32_rtems/fsfwconfig/objects/systemObjectList.h
Normal file
16
bsp_stm32_rtems/fsfwconfig/objects/systemObjectList.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
|
||||
#define FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
|
||||
|
||||
#include <commonSystemObjects.h>
|
||||
|
||||
namespace objects {
|
||||
enum mission_objects {
|
||||
/* 0x62 ('b') Board and mission specific objects */
|
||||
UDP_BRIDGE = 0x62000300,
|
||||
UDP_POLLING_TASK = 0x62000400,
|
||||
/* Generic name for FSFW static ID setter */
|
||||
DOWNLINK_DESTINATION = UDP_BRIDGE
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */
|
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Add polling sequence initialization which are not common to every BSP here.
|
||||
*/
|
||||
#include "pollingSequenceFactory.h"
|
||||
|
@ -0,0 +1,13 @@
|
||||
#ifndef POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_
|
||||
#define POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_
|
||||
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
class FixedTimeslotTaskIF;
|
||||
|
||||
namespace pst {
|
||||
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
|
||||
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF* thisSequence);
|
||||
}
|
||||
|
||||
#endif /* POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_ */
|
12
bsp_stm32_rtems/fsfwconfig/returnvalues/classIds.h
Normal file
12
bsp_stm32_rtems/fsfwconfig/returnvalues/classIds.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_
|
||||
#define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_
|
||||
|
||||
#include <commonConfig.h>
|
||||
|
||||
namespace CLASS_ID {
|
||||
enum classIds: uint8_t {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */
|
11
bsp_stm32_rtems/fsfwconfig/tmtc/apid.h
Normal file
11
bsp_stm32_rtems/fsfwconfig/tmtc/apid.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef FSFWCONFIG_TMTC_APID_H_
|
||||
#define FSFWCONFIG_TMTC_APID_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <commonConfig.h>
|
||||
|
||||
namespace apid {
|
||||
static const uint16_t APID = COMMON_APID;
|
||||
};
|
||||
|
||||
#endif /* FSFWCONFIG_TMTC_APID_H_ */
|
7
bsp_stm32_rtems/fsfwconfig/tmtc/pusIds.h
Normal file
7
bsp_stm32_rtems/fsfwconfig/tmtc/pusIds.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef FSFWCONFIG_TMTC_PUSIDS_H_
|
||||
#define FSFWCONFIG_TMTC_PUSIDS_H_
|
||||
|
||||
#include <commonConfig.h>
|
||||
|
||||
|
||||
#endif /* FSFWCONFIG_TMTC_PUSIDS_H_ */
|
14
bsp_stm32_rtems/init.c
Normal file
14
bsp_stm32_rtems/init.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "RTEMSConfig.h"
|
||||
|
||||
extern int main();
|
||||
|
||||
/**
|
||||
* Entry point for the RTEMS BSP after low level and RTEMS executive initialization.
|
||||
* @param argument
|
||||
* @return
|
||||
*/
|
||||
rtems_task Init(rtems_task_argument argument) {
|
||||
main();
|
||||
return (void) rtems_task_delete( RTEMS_SELF );
|
||||
}
|
||||
|
53
bsp_stm32_rtems/main.cpp
Normal file
53
bsp_stm32_rtems/main.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "core/ObjectFactory.h"
|
||||
#include "core/InitMission.h"
|
||||
#include <stm32h7xx_nucleo.h>
|
||||
#include <hardware_init.h>
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/timemanager/Clock.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/console.h>
|
||||
#include <rtems/rtems/clock.h>
|
||||
#include <mission/utility/compile_time.h>
|
||||
|
||||
#define BOARD_NAME "stm32h743zi-nucleo"
|
||||
|
||||
ObjectManagerIF *objectManager = nullptr;
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
ServiceInterfaceStream sif::debug("DEBUG", true);
|
||||
ServiceInterfaceStream sif::info("INFO", true);
|
||||
ServiceInterfaceStream sif::warning("WARNING", true);
|
||||
ServiceInterfaceStream sif::error("ERROR", true);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Core function for the RTEMS BSP, called in Init function.
|
||||
* @return
|
||||
* @author R. Mueller
|
||||
*/
|
||||
int main() {
|
||||
hardware_init();
|
||||
|
||||
printf("\n\r%s-- FSFW Example (RTEMS) --\n", sif::ANSI_COLOR_RESET);
|
||||
printf("-- Compiled for %s --\n", BOARD_NAME);
|
||||
printf("-- Compiled on %s %s --\n\r",__DATE__, __TIME__);
|
||||
|
||||
timeval timeToSet;
|
||||
timeToSet.tv_sec = UNIX_TIMESTAMP;
|
||||
timeToSet.tv_usec = 0;
|
||||
ReturnValue_t clockStatus = Clock::setClock(&timeToSet);
|
||||
if(clockStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::printError("Clock configuration failed!\n");
|
||||
}
|
||||
else {
|
||||
sif::printInfo("Clock configured successfully.\n");
|
||||
}
|
||||
objectManager = new ObjectManager(ObjectFactory::produce);
|
||||
objectManager->initialize();
|
||||
|
||||
InitMission::createTasks();
|
||||
}
|
Reference in New Issue
Block a user