This commit is contained in:
2025-05-13 04:55:13 +03:00
parent 3f693566bd
commit ceb6d0ccec
4364 changed files with 2897163 additions and 0 deletions
@@ -0,0 +1,304 @@
/*
*********************************************************************************************************
* uC/OS-View
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
* ST STM32 (Cortex-M3)
* IAR C Compiler
*
*
* Filename : OS_VIEWc.C
* Version : V1.21
* Programmer : zmt
*********************************************************************************************************
*/
#include <includes.h>
#if ( OS_VIEW_MODULE == DEF_ENABLED )
/*
*********************************************************************************************************
* OSView_TmrInit()
*
* Description : Select & initialize a timer for use with uC/OS-View.
*
* Argument(s) : none.
*
* Return(s) : none.
*********************************************************************************************************
*/
void OSView_TmrInit (void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0x00;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_SetCounter(TIM2, 0);
TIM_PrescalerConfig(TIM2, 256, TIM_PSCReloadMode_Immediate);
TIM_Cmd(TIM2, ENABLE);
}
/*
*********************************************************************************************************
* OSView_TmrRd()
*
* Description : Read the current counts of a 32-bit free running timer.
*
* Argument(s) : none.
*
* Return(s) : The 32 bit counts of the timer.
*********************************************************************************************************
*/
CPU_INT32U OSView_TmrRd (void)
{
return ((CPU_INT32U)TIM_GetCounter(TIM2));
}
/*
*********************************************************************************************************
* EXIT uC/OS-View
*
* Description: This function is called if your target needs to 'uninstall' uC/OS-View.
*
* Note(s) :
*********************************************************************************************************
*/
void OSView_Exit (void)
{
//NULL
}
/*
*********************************************************************************************************
* Obtain CPU name
*********************************************************************************************************
*/
void OSView_GetCPUName (INT8U *s)
{
INT8U cpu_clk_freq;
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
cpu_clk_freq = (INT8U)( ((CPU_INT32U)RCC_Clocks.SYSCLK_Frequency) / 1000000L);
strcpy((char *)s, "STM32F4xx (xxx MHz)");
s[11] = cpu_clk_freq / 100 + '0';
s[12] = cpu_clk_freq % 100 / 10 + '0';
s[13] = cpu_clk_freq % 100 % 10 + '0';
s[20] = '\0' ;
}
/*
*********************************************************************************************************
* Obtain Interrupt Stack information
*********************************************************************************************************
*/
INT32U OSView_GetIntStkBase (void)
{
return (0); /* We are not using an ISR stack */
}
INT32U OSView_GetIntStkSize (void)
{
return (0); /* We are not using an ISR stack */
}
/*$PAGE*/
/*
*********************************************************************************************************
* INITIALISE uC/OS-View COM PORT
*
* Description: Initialize the hardware required for the OS to run. This will work on any target hardware,
* but may have to be tailored a little (regarding the clock frequency). Of course the same
* holds true if for some reason you choose to use another timer.
*
* Note(s) : 1) This function assumes that a free running timer has been initialized. The timer can
* either be a 16 bits or 32 bits timer. Your application needs to provide a function
* called OSView_TmrRd() that reads the current counts of this timer. The free running
* timer is initialized by the BSP function OSView_TmrInit().
*********************************************************************************************************
*/
void OSView_InitTarget (INT32U baud_rate)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
OSView_TmrInit(); /* Initialize the free running timer */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
/* Configure USARTx_Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USARTx_Rx as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = baud_rate;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_ITConfig(OS_VIEW_USART,USART_IT_RXNE,ENABLE);
USART_Init(OS_VIEW_USART, &USART_InitStructure);
USART_Cmd(OS_VIEW_USART, ENABLE);
/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Rx Interrupts
*********************************************************************************************************
*/
void OSView_RxIntDis (void)
{
USART_ITConfig(OS_VIEW_USART, USART_IT_RXNE, DISABLE);
}
/*
*********************************************************************************************************
* Enable Rx Interrupts
*********************************************************************************************************
*/
void OSView_RxIntEn (void)
{
USART_ITConfig(OS_VIEW_USART, USART_IT_RXNE, ENABLE);
}
/*
*********************************************************************************************************
* Rx Communication handler for uC/OS-View
*
* Description: This function is called by OSView_RxISR (see OS_VIEWa.ASM) to process a received
* character interrupt.
*
* Note(s) : This adaptation of uC/OS-View assumes that a 'combined' interrupt is generated by the UART
* and thus this function is not needed.
*********************************************************************************************************
*/
void OSView_RxISRHandler (void)
{
//NULL
}
/*
*********************************************************************************************************
* Rx/Tx Communication handler for uC/OS-View
*
* Description: This function is called in stm32f10x_it.c
*********************************************************************************************************
*/
void OSView_RxTxISRHandler (void)
{
CPU_SR cpu_sr;
CPU_CRITICAL_ENTER(); /* Tell uC/OS-II that we are starting an ISR */
OSIntNesting++;
CPU_CRITICAL_EXIT();
if (USART_GetITStatus(OS_VIEW_USART, USART_IT_RXNE) != RESET) {
/* Read one byte from the receive data register */
OSView_RxHandler( USART_ReceiveData(OS_VIEW_USART) & 0xFF );
USART_ClearITPendingBit(OS_VIEW_USART, USART_IT_RXNE); /* Clear the USART Receive interrupt */
}
if (USART_GetITStatus(OS_VIEW_USART, USART_IT_TXE) != RESET) {
OSView_TxHandler();
USART_ClearITPendingBit(OS_VIEW_USART, USART_IT_TXE); /* Clear the USART transmit interrupt */
}
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
/*$PAGE*/
/*
*********************************************************************************************************
* Communication for uC/OS-View
*
* Description: Send 1 character to COM Port
*********************************************************************************************************
*/
void OSView_Tx1 (INT8U c)
{
USART_SendData(OS_VIEW_USART, c);
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntDis (void)
{
USART_ITConfig(OS_VIEW_USART, USART_IT_TXE, DISABLE);
}
/*
*********************************************************************************************************
* Enable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntEn (void)
{
USART_ITConfig(OS_VIEW_USART, USART_IT_TXE, ENABLE);
}
#endif /* end of #if ( OS_VIEW_MODULE == DEF_ENABLED ) */
@@ -0,0 +1,44 @@
/*
*********************************************************************************************************
* uC/OS-View
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
* ST STM32 (Cortex-M3)
* IAR C Compiler
*
*
* Filename : OS_VIEWc.H
* Version : V1.21.1
* Programmer : ZMT
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define OS_VIEW_PARSE_TASK DEF_ENABLED /* Parsing of received packets will be done by a task */
#define OS_VIEW_BAUDRATE 115200u /* RS232 communications baud rate between the windows application and embeded system */
#define OS_VIEW_USART USART1
/*
*********************************************************************************************************
* uC/OS-View CONFIGURATION
*********************************************************************************************************
*/
#define OS_VIEW_RX_BUF_SIZE 128u /* Rx buffer size (should not need to change) */
#define OS_VIEW_TX_BUF_SIZE 128u /* Tx buffer size ( 64~255 should not need to change) */
#define OS_VIEW_TX_STR_SIZE 128u /* Tx string size ( 64~255 should not need to change) */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,161 @@
/*
***********************************************************************************************
* uC/OS-View
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
*
* Filename : OS_VIEW.H
* Version : V1.33
* Programmer : JJL
***********************************************************************************************
*/
#ifdef OS_VIEW_GLOBALS
#define OS_VIEW_EXT
#else
#define OS_VIEW_EXT extern
#endif
#ifndef OS_VIEW_H
#define OS_VIEW_H
/*
***********************************************************************************************
* VARIABLES
***********************************************************************************************
*/
OS_VIEW_EXT INT32U OSView_CyclesCtr;
#if OS_VIEW_TMR_32_BITS > 0
OS_VIEW_EXT INT32U OSView_TmrCntsPrev;
#else
OS_VIEW_EXT INT16U OSView_TmrCntsPrev;
#endif
OS_VIEW_EXT INT8U OSView_RxState;
OS_VIEW_EXT INT8U OSView_RxRemainLen;
OS_VIEW_EXT INT8U OSView_RxChkSum;
OS_VIEW_EXT INT8U OSView_RxBuf[OS_VIEW_RX_BUF_SIZE];
OS_VIEW_EXT INT8U OSView_RxBufCnt;
OS_VIEW_EXT INT8U OSView_RxRdIx;
OS_VIEW_EXT INT32U OSView_RxCtr;
OS_VIEW_EXT INT16U OSView_RxPktCtr;
OS_VIEW_EXT INT16U OSView_TxLen;
OS_VIEW_EXT INT16U OSView_TxIx;
OS_VIEW_EXT INT8U OSView_TxChkSum;
OS_VIEW_EXT INT8U OSView_TxState;
OS_VIEW_EXT BOOLEAN OSView_TxActiveFlag;
OS_VIEW_EXT INT8U OSView_TxBuf[OS_VIEW_TX_BUF_SIZE];
OS_VIEW_EXT INT16U OSView_TxBufCnt;
OS_VIEW_EXT INT8U *OSView_TxBufPtr;
OS_VIEW_EXT INT32U OSView_TxCtr;
OS_VIEW_EXT INT16U OSView_TxPktCtr;
OS_VIEW_EXT INT16U OSView_TxStrLen;
OS_VIEW_EXT INT8U OSView_TxStrBuf[OS_VIEW_TX_STR_SIZE];
OS_VIEW_EXT INT16U OSView_TxStrDlyCtr;
OS_VIEW_EXT void (*OSView_TerminalRxCallbackFnct)(INT8U data);
/*
***********************************************************************************************
* PROTOTYPES
* (PORT INDEPENDENT)
***********************************************************************************************
*/
void OSView_Init(INT32U baud_rate); /* Initialize uC/OS-View */
void OSView_RxHandler(INT8U data); /* Processor independent Rx handler */
void OSView_TxHandler(void); /* Processor independent Tx handler */
void OSView_TxStr(INT8U *s, INT16U dly); /* Send an ASCII string to terminal window */
void OSView_TaskSwHook(void); /* MUST be called by OSTaskSwHook() */
void OSView_TaskCreateHook(OS_TCB *ptcb); /* MUST be called by OSTaskCreateHook() */
void OSView_TickHook(void); /* MUST be called by OSTimeTickHook() */
void OSView_Exit(void); /* Exit uC/OS-View */
void OSView_InitTarget(INT32U baud_rate); /* Initialize the target specifics */
void OSView_TerminalRxSetCallback(void (*call_back)(INT8U data));
void OSView_TerminalTx(INT8U data); /* Write data to output window */
INT32U OSView_TimeGetCycles(void); /* Function to read fine resolution time base */
void OSView_RxTxISR(void); /* Assembly Language Rx/Tx ISR */
void OSView_RxTxISRHandler(void); /* C code to process Rx or Tx character */
void OSView_RxISR(void); /* Assembly Language Rx ISR */
void OSView_RxISRHandler(void); /* C code to process character received */
void OSView_RxIntEn(void); /* Enable Rx interrupts */
void OSView_RxIntDis(void); /* Disable Rx interrupts */
void OSView_TxISR(void); /* Assembly Language Tx ISR */
void OSView_TxISRHandler(void); /* C code to process next character to send */
void OSView_TxIntEn(void); /* Enable Tx interrupts */
void OSView_TxIntDis(void); /* Disable Tx interrupts */
void OSView_Tx1(INT8U c); /* Function to send a single character */
void OSView_GetCPUName(INT8U *s); /* Returns the name of the CPU used */
INT32U OSView_GetIntStkBase(void); /* Get the address of the interrupt stack base */
INT32U OSView_GetIntStkSize(void); /* Get the address of the interrupt stack size */
/*
*********************************************************************************************************
* BSP FUNCTION PROTOTYPES
*********************************************************************************************************
*/
void OSView_TmrInit(void); /* Initialize the free running timer */
INT32U OSView_TmrRd(void); /* Read the free running timer */
/*
***********************************************************************************************
* #error DIRECTIVES
***********************************************************************************************
*/
#if OS_VIEW_PARSE_TASK > 0 && (OS_SEM_EN == 0 && OS_MBOX_EN == 0)
#error "Semaphore or Mailbox management must be enabled. In other words, OS_SEM_EN or OS_MBOX_EN must be set to 1."
#endif
#if OS_TIME_GET_SET_EN == 0
#error "OS_CFG.H, OS_TIME_GET_SET_EN needs to be set to 1 to include code for OSTimeGet()"
#endif
#if OS_TASK_CREATE_EXT_EN == 0
#error "OS_CFG.H, OS_TASK_CREATE_EXT_EN needs to be set to 1 to include code for OSTaskCreateExt()"
#endif
#if OS_TASK_STAT_EN == 0
#error "OS_CFG.H, OS_TASK_STAT_EN needs to be set to 1 to include code for the statistics task"
#endif
#if OS_TASK_STAT_STK_CHK_EN == 0
#error "OS_CFG.H, OS_TASK_STAT_STK_CHK_EN needs to be set to 1 to include code for task stack checking"
#endif
#if OS_TASK_PROFILE_EN == 0
#error "OS_CFG.H, OS_TASK_PROFILE_EN needs to be set to 1 to enable task profiling"
#endif
#if OS_MAX_TASKS > 61
#error "OS_CFG.H, OS_MAX_TASKS cannot be higher than 61 when using uC/OS-View"
#endif
#if OS_SEM_EN == 0
#error "OS_CFG.H, uC/OS-View requires to you enable semaphores, set OS_SEM_EN to 1"
#endif
#if OS_VIEW_TMR_32_BITS > 1
#error "OS_VIEW_TMR_32_BITS 'must' be defined to either 0 (for 16 bit timer) or 1 (for 32 bit timer)"
#endif
#endif