Initial commit

This commit is contained in:
OneOfEleven
2023-09-09 08:03:56 +01:00
parent 92305117f1
commit 54441e27d9
3388 changed files with 582553 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
The RTX_Blinky project is a simple RTX Kernel based example
for a simulated Cortex-M3 device
Example functionality:
- Clock Settings:
- XTAL = 50 MHz
- Core = 25 MHz
The simple RTX Kernel based example simulates the step-motor
driver. Four LEDs are blinking simulating the activation of
the four output driver stages
The simulation does not provide LEDs, so the state changes
are output on the Debug printf window:
- phase A
- phase B
- phase C
- phase D
This example simulates Half step driver mode and
CW rotation direction.
The BLINKY example program is available for one target:
Simulation: configured for a simulated on-chip Flash
The example is compatible with other Cortex-M class devices.
Simply open the project settings, navigate to Device tab and
select another Cortex-M class device.

View File

@@ -0,0 +1,165 @@
/* --------------------------------------------------------------------------
* Copyright (c) 2013-2019 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Name: Blinky.c
* Purpose: RTX example program
*
*---------------------------------------------------------------------------*/
#include <stdio.h>
#include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5
#include "RTE_Components.h"
#include CMSIS_device_header
osThreadId_t tid_phaseA; /* Thread id of thread: phase_a */
osThreadId_t tid_phaseB; /* Thread id of thread: phase_b */
osThreadId_t tid_phaseC; /* Thread id of thread: phase_c */
osThreadId_t tid_phaseD; /* Thread id of thread: phase_d */
osThreadId_t tid_clock; /* Thread id of thread: clock */
struct phases_t {
int_fast8_t phaseA;
int_fast8_t phaseB;
int_fast8_t phaseC;
int_fast8_t phaseD;
} g_phases;
/*----------------------------------------------------------------------------
* Switch LED on
*---------------------------------------------------------------------------*/
void Switch_On (unsigned char led) {
printf("LED On: #%d\n\r", led);
}
/*----------------------------------------------------------------------------
* Switch LED off
*---------------------------------------------------------------------------*/
void Switch_Off (unsigned char led) {
printf("LED Off: #%d\n\r", led);
}
/*----------------------------------------------------------------------------
* Function 'signal_func' called from multiple threads
*---------------------------------------------------------------------------*/
void signal_func (osThreadId_t tid) {
osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
osDelay(500); /* delay 500ms */
osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
osDelay(500); /* delay 500ms */
osThreadFlagsSet(tid, 0x0001); /* set signal to thread 'thread' */
osDelay(500); /* delay 500ms */
}
/*----------------------------------------------------------------------------
* Thread 1 'phaseA': Phase A output
*---------------------------------------------------------------------------*/
void phaseA (void *argument) {
for (;;) {
osThreadFlagsWait(0x0001, osFlagsWaitAny ,osWaitForever); /* wait for an event flag 0x0001 */
Switch_On(0);
g_phases.phaseA = 1;
signal_func(tid_phaseB); /* call common signal function */
g_phases.phaseA = 0;
Switch_Off(0);
}
}
/*----------------------------------------------------------------------------
* Thread 2 'phaseB': Phase B output
*---------------------------------------------------------------------------*/
void phaseB (void *argument) {
for (;;) {
osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
Switch_On(1);
g_phases.phaseB = 1;
signal_func(tid_phaseC); /* call common signal function */
g_phases.phaseB = 0;
Switch_Off(1);
}
}
/*----------------------------------------------------------------------------
* Thread 3 'phaseC': Phase C output
*---------------------------------------------------------------------------*/
void phaseC (void *argument) {
for (;;) {
osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
Switch_On(2);
g_phases.phaseC = 1;
signal_func(tid_phaseD); /* call common signal function */
g_phases.phaseC = 0;
Switch_Off(2);
}
}
/*----------------------------------------------------------------------------
* Thread 4 'phaseD': Phase D output
*---------------------------------------------------------------------------*/
void phaseD (void *argument) {
for (;;) {
osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
Switch_On(3);
g_phases.phaseD = 1;
signal_func(tid_phaseA); /* call common signal function */
g_phases.phaseD = 0;
Switch_Off(3);
}
}
/*----------------------------------------------------------------------------
* Thread 5 'clock': Signal Clock
*---------------------------------------------------------------------------*/
void clock (void *argument) {
for (;;) {
osThreadFlagsWait(0x0100, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0100 */
osDelay(80); /* delay 80ms */
}
}
/*----------------------------------------------------------------------------
* Main: Initialize and start RTX Kernel
*---------------------------------------------------------------------------*/
void app_main (void *argument) {
tid_phaseA = osThreadNew(phaseA, NULL, NULL);
tid_phaseB = osThreadNew(phaseB, NULL, NULL);
tid_phaseC = osThreadNew(phaseC, NULL, NULL);
tid_phaseD = osThreadNew(phaseD, NULL, NULL);
tid_clock = osThreadNew(clock, NULL, NULL);
osThreadFlagsSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */
osDelay(osWaitForever);
}
int main (void) {
// System Initialization
SystemCoreClockUpdate();
// ...
osKernelInitialize(); // Initialize CMSIS-RTOS
osThreadNew(app_main, NULL, NULL); // Create application main thread
if (osKernelGetState() == osKernelReady) {
osKernelStart(); // Start thread execution
}
while(1);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<crun>
<version>1</version>
<filter_entries>
<filter index="0" type="default">
<type>*</type>
<start_file>*</start_file>
<end_file>*</end_file>
<action_debugger>0</action_debugger>
<action_log>1</action_log>
</filter>
</filter_entries>
</crun>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,100 @@
<?xml version="1.0"?>
<settings>
<Stack>
<FillEnabled>0</FillEnabled>
<OverflowWarningsEnabled>1</OverflowWarningsEnabled>
<WarningThreshold>90</WarningThreshold>
<SpWarningsEnabled>1</SpWarningsEnabled>
<WarnLogOnly>1</WarnLogOnly>
<UseTrigger>1</UseTrigger>
<TriggerName>main</TriggerName>
<LimitSize>0</LimitSize>
<ByteLimit>50</ByteLimit>
</Stack>
<Trace1>
<Enabled>0</Enabled>
<ShowSource>1</ShowSource>
</Trace1>
<DebugChecksum>
<Checksum>3153441700</Checksum>
</DebugChecksum>
<Disassembly>
<InstrCount>0</InstrCount>
<MixedMode>1</MixedMode>
</Disassembly>
<CodeCoverage>
<Enabled>0</Enabled>
<ShowSource>0</ShowSource>
<HideCovered>0</HideCovered>
</CodeCoverage>
<Exceptions>
<StopOnUncaught>_ 0</StopOnUncaught>
<StopOnThrow>_ 0</StopOnThrow>
</Exceptions>
<CallStack>
<ShowArgs>0</ShowArgs>
</CallStack>
<DriverProfiling>
<Enabled>0</Enabled>
<Mode>1</Mode>
<Graph>0</Graph>
<Symbiont>0</Symbiont>
</DriverProfiling>
<CallStackLog>
<Enabled>0</Enabled>
</CallStackLog>
<CallStackStripe>
<ShowTiming>1</ShowTiming>
</CallStackStripe>
<TermIOLog>
<LoggingEnabled>_ 0</LoggingEnabled>
<LogFile>_ ""</LogFile>
</TermIOLog>
<LogFile>
<LoggingEnabled>_ 0</LoggingEnabled>
<LogFile>_ ""</LogFile>
<Category>_ 0</Category>
</LogFile>
<InterruptLog>
<LogEnabled>0</LogEnabled>
<GraphEnabled>0</GraphEnabled>
<ShowTimeLog>1</ShowTimeLog>
<SumEnabled>0</SumEnabled>
<ShowTimeSum>1</ShowTimeSum>
<SumSortOrder>0</SumSortOrder>
</InterruptLog>
<DataLog>
<LogEnabled>0</LogEnabled>
<GraphEnabled>0</GraphEnabled>
<ShowTimeLog>1</ShowTimeLog>
<SumEnabled>0</SumEnabled>
<ShowTimeSum>1</ShowTimeSum>
</DataLog>
<DisassembleMode>
<mode>0</mode>
</DisassembleMode>
<Breakpoints2>
<Count>0</Count>
</Breakpoints2>
<Interrupts>
<Enabled>1</Enabled>
<Irq0>_ 0 400000 0 10000 0 0 100 100 0 1 "SysTick 1 0x3C"</Irq0>
<Count>1</Count>
</Interrupts>
<MemConfig>
<Base>1</Base>
<Manual>0</Manual>
<Ddf>1</Ddf>
<TypeViol>0</TypeViol>
<Stop>1</Stop>
</MemConfig>
<Aliases>
<Count>0</Count>
<SuppressDialog>0</SuppressDialog>
</Aliases>
<Simulator>
<Freq>10000000</Freq>
<FreqHi>0</FreqHi>
<MultiCoreRunAll>1</MultiCoreRunAll>
</Simulator>
</settings>