0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-20 15:08:37 +03:00

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>

View File

@ -0,0 +1,16 @@
The MsgQueue project is a simple RTX Kernel based example
for a simulated Cortex-M3 device
Example functionality:
- Clock Settings:
- XTAL = 12 MHz
- Core = 12 MHz
The simple RTX Kernel based example shows how to use a
message queue to send data from one thread to another.
The message receiver thread prints the message contents
to the debug output window.
The MsgQueue example program is available for one target:
Simulation: configured for a simulated on-chip Flash

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>2135918346</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>

View File

@ -0,0 +1,120 @@
/* --------------------------------------------------------------------------
* 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: main.c
* Purpose: RTX example program
*
*---------------------------------------------------------------------------*/
#include <stdio.h>
#include "RTE_Components.h"
#include CMSIS_device_header
#include "cmsis_os2.h"
void app_main (void *argument);
void app_msg (void *argument);
typedef struct msg_s {
uint8_t cmd;
uint8_t len;
uint8_t data[8];
} msg_t;
static osMessageQueueId_t msgQueue;
static const osThreadAttr_t msgAttr = {
.stack_size = 400U
};
/*----------------------------------------------------------------------------
* Application main thread
*---------------------------------------------------------------------------*/
void app_main (void *argument) {
(void)argument;
osStatus_t status;
uint32_t cnt = 0UL;
msg_t msg = {
.cmd = 1U,
.len = 4U,
.data = { 0U }
};
while (1) {
// Produce a new message and put it to the queue
++cnt;
*((uint32_t*)msg.data) = cnt;
status = osMessageQueuePut(msgQueue, &msg, 0U, osWaitForever);
if (status != osOK) {
printf("app_main: osMessageQueuePut failed.\n");
}
// Defer message creation
osDelay(osMessageQueueGetCount(msgQueue)*100U);
}
}
/*----------------------------------------------------------------------------
* Application message receiver thread
*---------------------------------------------------------------------------*/
void app_msg (void *argument) {
(void)argument;
osStatus_t status;
uint32_t cnt;
msg_t msg;
while (1) {
// Defer message processing
osDelay(osMessageQueueGetSpace(msgQueue)*100U);
// Wait forever until a message could be received
status = osMessageQueueGet(msgQueue, &msg, NULL, osWaitForever);
if (status != osOK) {
printf("app_msg: osMessageQueueGet failed.\n");
} else {
if (msg.len == 4U) {
cnt = *((uint32_t*)msg.data);
}
printf("app_msg: received [cmd = %d, data = 0x%0X]\n", msg.cmd, cnt);
}
}
}
/*----------------------------------------------------------------------------
* Main entry
*---------------------------------------------------------------------------*/
int main (void) {
// System Initialization
SystemCoreClockUpdate();
osKernelInitialize(); // Initialize CMSIS-RTOS
osThreadNew(app_main, NULL, NULL); // Create application main thread
osThreadNew(app_msg, NULL, &msgAttr); // Create message receiver thread
// Create message queue for up to 10 messages of type msg_t
msgQueue = osMessageQueueNew(10, sizeof(msg_t), NULL);
osKernelStart(); // Start thread execution
for (;;) {}
}