support task self delete for STM8, add a sample of shell for STM8

1. sample project, see TencentOS-tiny\board\STM8L052R8T6\IAR\shell
2. ATTENTION: read TencentOS-tiny\board\STM8L052R8T6\IAR\shell\README.md first
This commit is contained in:
daishengdong
2020-02-15 23:22:38 +08:00
parent 7a0966a2cc
commit 3ddeb9c5cd
34 changed files with 7181 additions and 191 deletions

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -54,7 +54,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -13,7 +13,6 @@ typedef uint32_t cpu_data_t;
typedef uint32_t cpu_addr_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -50,7 +50,6 @@ typedef uint32_t cpu_hrtimer_t;
typedef uint32_t cpu_hrtimer_t;
#endif
//typedef cpu_addr_t size_t;
typedef cpu_addr_t cpu_cpsr_t;
#endif

View File

@@ -210,6 +210,9 @@ __KNL__ k_stack_t *cpu_task_stk_init(void *entry,
}
#endif
*--sp = (cpu_data_t)((uint16_t)exit & 0xFF); /* LRL */
*--sp = (cpu_data_t)(((uint16_t)exit >> 8) & 0xFF); /* LRH */
*--sp = (cpu_data_t)((uint16_t)entry & 0xFF); /* PCL */
*--sp = (cpu_data_t)(((uint16_t)entry >> 8) & 0xFF); /* PCH */

View File

@@ -40,7 +40,6 @@ port_cpsr_restore
*/
PUSH A
POP CC
RIM
RET

View File

@@ -0,0 +1,17 @@
#include "tos_hal.h"
#include "stm8l15x.h"
int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port)
{
}
int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout)
{
int i = 0;
for (i = 0; i < size; ++i) {
UART1_Send_Byte(buf[i]);
}
}

View File

@@ -1,8 +1,20 @@
#include "stm8l15x.h"
#include "uart.h"
#include "stdio.h"
const uint8_t HEX_TABLE[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int putchar(int c) {
if('\n' == (char)c) {
USART_SendData8(USART1, '\r');
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
}
USART_SendData8(USART1, c);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
return (c);
}
void UART1_Send_Byte(uint8_t ucData)
{
USART_SendData8(USART1, ucData);
@@ -110,6 +122,9 @@ void UART1_Init(uint32_t uiBaudRate)
USART_Init(USART1, uiBaudRate, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No,
(USART_Mode_TypeDef)(USART_Mode_Tx | USART_Mode_Rx));
// enable RX interrupt
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
// enable UART1
USART_Cmd(USART1, ENABLE);
}

File diff suppressed because one or more lines are too long

View File

@@ -49,7 +49,7 @@
<MultiCoreRunAll>1</MultiCoreRunAll>
</Simulator>
<DebugChecksum>
<Checksum>941507234</Checksum>
<Checksum>4271934099</Checksum>
</DebugChecksum>
<CallStack>
<ShowArgs>0</ShowArgs>
@@ -96,8 +96,9 @@
<Bp21>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.293.5" 0 0 0 0 "" 0 ""</Bp21>
<Bp22>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.293.5" 0 0 0 0 "" 0 ""</Bp22>
<Bp23>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.299.9" 0 0 0 0 "" 0 ""</Bp23>
<Bp24>_ "STD_CODE" "{$PROJ_DIR$\..\..\USER\stm8l15x_it.c}.293.5" 1 0 0 0 "" 0 ""</Bp24>
<Count>25</Count>
<Bp24>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.94.5" 0 0 0 0 "" 0 ""</Bp24>
<Bp25>_ "STD_CODE" "{$PROJ_DIR$\..\..\USER\main.c}.94.5" 1 0 0 0 "" 0 ""</Bp25>
<Count>26</Count>
</Breakpoints>
<Aliases>
<Count>0</Count>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
- set your uart's baudrate to 9600, too high may not work
- replace all the tos_mmheap_alloc in tos_shell.c with malloc
replace all the tos_mmheap_free in tos_shell.c with free
That means we would not use tos_mmheap in STM8

View File

@@ -0,0 +1,40 @@
@REM This batch file has been generated by the IAR Embedded Workbench
@REM C-SPY Debugger, as an aid to preparing a command line for running
@REM the cspybat command line utility using the appropriate settings.
@REM
@REM Note that this file is generated every time a new debug session
@REM is initialized, so you may want to move or rename the file before
@REM making changes.
@REM
@REM You can launch cspybat by typing the name of this batch file followed
@REM by the name of the debug file (usually an ELF/DWARF or UBROF file).
@REM
@REM Read about available command line parameters in the C-SPY Debugging
@REM Guide. Hints about additional command line parameters that may be
@REM useful in specific cases:
@REM --download_only Downloads a code image without starting a debug
@REM session afterwards.
@REM --silent Omits the sign-on message.
@REM --timeout Limits the maximum allowed execution time.
@REM
@echo off
if not "%~1" == "" goto debugFile
@echo on
"D:\Program Files\Embedded Workbench 8.3 STM8\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.general.xcl" --backend -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.driver.xcl"
@echo off
goto end
:debugFile
@echo on
"D:\Program Files\Embedded Workbench 8.3 STM8\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.general.xcl" "--debug_file=%~1" --backend -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.driver.xcl"
@echo off
:end

View File

@@ -0,0 +1,31 @@
param([String]$debugfile = "");
# This powershell file has been generated by the IAR Embedded Workbench
# C - SPY Debugger, as an aid to preparing a command line for running
# the cspybat command line utility using the appropriate settings.
#
# Note that this file is generated every time a new debug session
# is initialized, so you may want to move or rename the file before
# making changes.
#
# You can launch cspybat by typing Powershell.exe -File followed by the name of this batch file, followed
# by the name of the debug file (usually an ELF / DWARF or UBROF file).
#
# Read about available command line parameters in the C - SPY Debugging
# Guide. Hints about additional command line parameters that may be
# useful in specific cases :
# --download_only Downloads a code image without starting a debug
# session afterwards.
# --silent Omits the sign - on message.
# --timeout Limits the maximum allowed execution time.
#
if ($debugfile -eq "")
{
& "D:\Program Files\Embedded Workbench 8.3 STM8\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.general.xcl" --backend -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.driver.xcl"
}
else
{
& "D:\Program Files\Embedded Workbench 8.3 STM8\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.general.xcl" --debug_file=$debugfile --backend -f "D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\settings\stm8_project.Debug.driver.xcl"
}

View File

@@ -0,0 +1,11 @@
"-p"
"D:\Program Files\Embedded Workbench 8.3 STM8\stm8\config\ddf\iostm8l052r8.ddf"
"--mcuname"
"STM8L052R8"

View File

@@ -0,0 +1,11 @@
"D:\Program Files\Embedded Workbench 8.3 STM8\stm8\bin\stm8proc.dll"
"D:\Program Files\Embedded Workbench 8.3 STM8\stm8\bin\stm8stlink.dll"
"D:\TOS\TencentOS-tiny\board\STM8L052R8T6\IAR\shell\Debug\Exe\stm8_project.out"
--plugin="D:\Program Files\Embedded Workbench 8.3 STM8\stm8\bin\stm8bat.dll"

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,114 @@
<?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>
<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>
<Breakpoints2>
<Count>0</Count>
</Breakpoints2>
<Interrupts>
<Enabled>1</Enabled>
</Interrupts>
<MemConfig>
<Base>1</Base>
<Manual>0</Manual>
<Ddf>1</Ddf>
<TypeViol>0</TypeViol>
<Stop>1</Stop>
</MemConfig>
<Simulator>
<Freq>16000000</Freq>
<FreqHi>0</FreqHi>
<MultiCoreRunAll>1</MultiCoreRunAll>
</Simulator>
<DebugChecksum>
<Checksum>407403705</Checksum>
</DebugChecksum>
<CallStack>
<ShowArgs>0</ShowArgs>
</CallStack>
<Disassembly>
<MixedMode>1</MixedMode>
</Disassembly>
<DataSample>
<LogEnabled>0</LogEnabled>
<GraphEnabled>0</GraphEnabled>
<ShowTimeLog>1</ShowTimeLog>
</DataSample>
<TermIOLog>
<LoggingEnabled>_ 0</LoggingEnabled>
<LogFile>_ ""</LogFile>
</TermIOLog>
<LogFile>
<LoggingEnabled>_ 0</LoggingEnabled>
<LogFile>_ ""</LogFile>
<Category>_ 0</Category>
</LogFile>
<Breakpoints>
<Bp0>_ "STD_CODE" "0x008960" 0 0 0 0 "" 0 ""</Bp0>
<Bp1>_ "STD_CODE" "0x008961" 0 0 0 0 "" 0 ""</Bp1>
<Bp2>_ "STD_CODE" "0x0088AE" 0 0 0 0 "" 0 ""</Bp2>
<Bp3>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\kernel\core\tos_task.c}.351.5" 0 0 0 0 "" 0 ""</Bp3>
<Bp4>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.238.1" 0 0 0 0 "" 0 ""</Bp4>
<Bp5>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.85.9" 0 0 0 0 "" 0 ""</Bp5>
<Bp6>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.211.1" 0 0 0 0 "" 0 ""</Bp6>
<Bp7>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.238.1" 0 0 0 0 "" 0 ""</Bp7>
<Bp8>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.232.1" 0 0 0 0 "" 0 ""</Bp8>
<Bp9>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.232.1" 0 0 0 0 "" 0 ""</Bp9>
<Bp10>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.138.5" 0 0 0 0 "" 0 ""</Bp10>
<Bp11>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.106.9" 0 0 0 0 "" 0 ""</Bp11>
<Bp12>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.96.1" 0 0 0 0 "" 0 ""</Bp12>
<Bp13>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.149.5" 0 0 0 0 "" 0 ""</Bp13>
<Bp14>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.107.9" 0 0 0 0 "" 0 ""</Bp14>
<Bp15>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.293.5" 0 0 0 0 "" 0 ""</Bp15>
<Bp16>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.100.1" 0 0 0 0 "" 0 ""</Bp16>
<Bp17>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.91.1" 0 0 0 0 "" 0 ""</Bp17>
<Bp18>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.96.1" 0 0 0 0 "" 0 ""</Bp18>
<Bp19>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.293.5" 0 0 0 0 "" 0 ""</Bp19>
<Bp20>_ "STD_CODE" "{D:\TOS\TencentOS-tiny}.293.5" 0 0 0 0 "" 0 ""</Bp20>
<Bp21>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.293.5" 0 0 0 0 "" 0 ""</Bp21>
<Bp22>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.299.9" 0 0 0 0 "" 0 ""</Bp22>
<Bp23>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.439.5" 0 0 0 0 "" 0 ""</Bp23>
<Bp24>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\components\shell\tos_shell.c}.129.13" 1 0 0 0 "" 0 ""</Bp24>
<Bp25>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\components\shell\tos_shell.c}.138.11" 1 0 0 0 "" 0 ""</Bp25>
<Bp26>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\board\STM8L052R8T6}.441.5" 0 0 0 0 "" 0 ""</Bp26>
<Bp27>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\components\shell\tos_shell.c}.33.5" 1 0 0 0 "" 0 ""</Bp27>
<Bp28>_ "STD_CODE" "{D:\TOS\TencentOS-tiny\components\shell\tos_shell.c}.222.1" 1 0 0 0 "" 0 ""</Bp28>
<Count>29</Count>
</Breakpoints>
<Aliases>
<Count>0</Count>
<SuppressDialog>0</SuppressDialog>
</Aliases>
<DebuggerSettings>
<DisableInterruptsWhenStepping>0</DisableInterruptsWhenStepping>
<LeaveTargetRunning>0</LeaveTargetRunning>
</DebuggerSettings>
</settings>

View File

@@ -0,0 +1 @@


File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,454 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<fileVersion>3</fileVersion>
<configuration>
<name>Debug</name>
<toolchain>
<name>STM8</name>
</toolchain>
<debug>1</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>1</archiveVersion>
<data>
<version>1</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CSpyMandatory</name>
<state>1</state>
</option>
<option>
<name>CSpyInput</name>
<state>1</state>
</option>
<option>
<name>CSpyRunToEnable</name>
<state>1</state>
</option>
<option>
<name>CSpyRunToName</name>
<state>main</state>
</option>
<option>
<name>CSpyMacOverride</name>
<state>0</state>
</option>
<option>
<name>CSpyMacFile</name>
<state></state>
</option>
<option>
<name>DynDriver</name>
<state>STLINK_STM8</state>
</option>
<option>
<name>CSpyDDFOverride</name>
<state>0</state>
</option>
<option>
<name>CSpyDDFFile</name>
<state>$TOOLKIT_DIR$\config\ddf\iostm8l052r8.ddf</state>
</option>
<option>
<name>CSpyEnableExtraOptions</name>
<state>0</state>
</option>
<option>
<name>CSpyExtraOptions</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath1</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath2</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath3</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset1</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset2</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset3</name>
<state></state>
</option>
<option>
<name>CSpyImagesUse1</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesUse2</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesUse3</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIMULATOR_STM8</name>
<archiveVersion>1</archiveVersion>
<data>
<version>0</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>SimMandatory</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>STICE_STM8</name>
<archiveVersion>3</archiveVersion>
<data>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>STiceMandatory</name>
<state>0</state>
</option>
<option>
<name>STiceSuppressLoad</name>
<state>0</state>
</option>
<option>
<name>STiceVerifyLoad</name>
<state>0</state>
</option>
<option>
<name>STiceLogFileOver</name>
<state>0</state>
</option>
<option>
<name>STiceLogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>STiceUseSwim</name>
<state>0</state>
</option>
<option>
<name>STiceOptionBytesSetupFileOver</name>
<state>0</state>
</option>
<option>
<name>STiceOptionBytesSetupFile</name>
<state></state>
</option>
<option>
<name>STiceEraseMemory</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>STLINK_STM8</name>
<archiveVersion>3</archiveVersion>
<data>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>STlinkMandatory</name>
<state>0</state>
</option>
<option>
<name>STlinkSuppressLoad</name>
<state>0</state>
</option>
<option>
<name>STlinkVerifyLoad</name>
<state>0</state>
</option>
<option>
<name>STlinkLogFileOver</name>
<state>0</state>
</option>
<option>
<name>STlinkLogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>STlinkOptionBytesSetupFileOver</name>
<state>0</state>
</option>
<option>
<name>STlinkOptionBytesSetupFile</name>
<state></state>
</option>
<option>
<name>STlinkEraseMemory</name>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
<configuration>
<name>Release</name>
<toolchain>
<name>STM8</name>
</toolchain>
<debug>0</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>1</archiveVersion>
<data>
<version>1</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>CSpyMandatory</name>
<state>1</state>
</option>
<option>
<name>CSpyInput</name>
<state>1</state>
</option>
<option>
<name>CSpyRunToEnable</name>
<state>1</state>
</option>
<option>
<name>CSpyRunToName</name>
<state>main</state>
</option>
<option>
<name>CSpyMacOverride</name>
<state>0</state>
</option>
<option>
<name>CSpyMacFile</name>
<state></state>
</option>
<option>
<name>DynDriver</name>
<state>SIMULATOR_STM8</state>
</option>
<option>
<name>CSpyDDFOverride</name>
<state>0</state>
</option>
<option>
<name>CSpyDDFFile</name>
<state></state>
</option>
<option>
<name>CSpyEnableExtraOptions</name>
<state>0</state>
</option>
<option>
<name>CSpyExtraOptions</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath1</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath2</name>
<state></state>
</option>
<option>
<name>CSpyImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesPath3</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset1</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset2</name>
<state></state>
</option>
<option>
<name>CSpyImagesOffset3</name>
<state></state>
</option>
<option>
<name>CSpyImagesUse1</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesUse2</name>
<state>0</state>
</option>
<option>
<name>CSpyImagesUse3</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIMULATOR_STM8</name>
<archiveVersion>1</archiveVersion>
<data>
<version>0</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>SimMandatory</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>STICE_STM8</name>
<archiveVersion>3</archiveVersion>
<data>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>STiceMandatory</name>
<state>0</state>
</option>
<option>
<name>STiceSuppressLoad</name>
<state>0</state>
</option>
<option>
<name>STiceVerifyLoad</name>
<state>0</state>
</option>
<option>
<name>STiceLogFileOver</name>
<state>0</state>
</option>
<option>
<name>STiceLogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>STiceUseSwim</name>
<state>0</state>
</option>
<option>
<name>STiceOptionBytesSetupFileOver</name>
<state>0</state>
</option>
<option>
<name>STiceOptionBytesSetupFile</name>
<state></state>
</option>
<option>
<name>STiceEraseMemory</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>STLINK_STM8</name>
<archiveVersion>3</archiveVersion>
<data>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>STlinkMandatory</name>
<state>0</state>
</option>
<option>
<name>STlinkSuppressLoad</name>
<state>0</state>
</option>
<option>
<name>STlinkVerifyLoad</name>
<state>0</state>
</option>
<option>
<name>STlinkLogFileOver</name>
<state>0</state>
</option>
<option>
<name>STlinkLogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>STlinkOptionBytesSetupFileOver</name>
<state>0</state>
</option>
<option>
<name>STlinkOptionBytesSetupFile</name>
<state></state>
</option>
<option>
<name>STlinkEraseMemory</name>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
</project>

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,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<workspace>
<project>
<path>$WS_DIR$\stm8_project.ewp</path>
</project>
<batchBuild />
</workspace>

View File

@@ -79,20 +79,13 @@ k_stack_t task1_stack[512];
k_task_t task2;
k_stack_t task2_stack[512];
int main(void)
#define APPLICATION_TASK_STK_SIZE 1024
k_task_t task_app;
k_stack_t task_app_stack[512];
__WEAK__ void application_entry(void * arg)
{
LED_GPIO_Init();
UART1_Init(57600); /* Init the UART1, baud rate 57600 */
RTC_Setting_Init(); /* Init RTC */
/* use as systick, interrupt handler see TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler */
Timer2_Init(TOS_CFG_CPU_CLOCK, TOS_CFG_CPU_TICK_PER_SECOND);
LED_On();
UART1_Send_String("welcome to TencentOS tiny!\r\n");
tos_knl_init();
tos_task_create(&task1, "task1", task1_entry, NULL,
4,
task1_stack, sizeof(task1_stack),
@@ -102,6 +95,27 @@ int main(void)
4,
task2_stack, sizeof(task2_stack),
0);
}
int main(void)
{
LED_GPIO_Init();
UART1_Init(9600); /* Init the UART1, baud rate 9600 */
RTC_Setting_Init(); /* Init RTC */
/* use as systick, interrupt handler see TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler */
Timer2_Init(TOS_CFG_CPU_CLOCK, TOS_CFG_CPU_TICK_PER_SECOND);
LED_On();
UART1_Send_String("welcome to TencentOS tiny!\r\n");
printf("welcome to TencentOS tiny!\r\n");
tos_knl_init();
tos_task_create(&task_app, "app", application_entry, NULL,
4,
task_app_stack, sizeof(task_app_stack),
0);
tos_knl_start();

View File

@@ -291,7 +291,6 @@ INTERRUPT_HANDLER(TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler, 19)
*/
TIM2_ClearITPendingBit(TIM2_IT_Update);
//UART1_Send_String("tim\r\n");
if (tos_knl_is_running()) {
tos_knl_irq_enter();
@@ -433,6 +432,7 @@ INTERRUPT_HANDLER(USART1_RX_TIM5_CC_IRQHandler, 28)
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
#ifdef USE_STM8L1526_EVAL
uint8_t temp;

View File

@@ -0,0 +1,475 @@
/**
******************************************************************************
* @file USART/USART_HyperTerminal_Interrupts/stm8l15x_it.c
* @author MCD Application Team
* @version V1.5.2
* @date 30-September-2014
* @brief Main Interrupt Service Routines.
* This file provides template for all peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8l15x_it.h"
#include "stm8l15x_usart.h"
#include "tos_k.h"
#include "tos_shell.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define TX_BUFFER_SIZE (countof(TxBuffer) - 1)
/* Private macro -------------------------------------------------------------*/
#define countof(a) (sizeof(a) / sizeof(*(a)))
/* Private variables ---------------------------------------------------------*/
uint8_t TxBuffer[] = "\n\rUSART Example: USART-Hyperterminal communication using Interrupt\nEnter your Text\n\r";
uint8_t TxCounter = 0;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
#ifdef _COSMIC_
/**
* @brief Dummy interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif
/**
* @brief TRAP interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief FLASH Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(FLASH_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief DMA1 channel0 and channel1 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(DMA1_CHANNEL0_1_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief DMA1 channel2 and channel3 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(DMA1_CHANNEL2_3_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief RTC / CSS_LSE Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(RTC_CSSLSE_IRQHandler, 4)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PORTE/F and PVD Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTIE_F_PVD_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PORTB / PORTG Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTIB_G_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PORTD /PORTH Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTID_H_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN0 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI0_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN1 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI1_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN2 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI2_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN3 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI3_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN4 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI4_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN5 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI5_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN6 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI6_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External IT PIN7 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI7_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief LCD /AES Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(LCD_AES_IRQHandler, 16)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CLK switch/CSS/TIM1 break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SWITCH_CSS_BREAK_DAC_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief ADC1/Comparator Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC1_COMP_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief TIM2 Update/Overflow/Trigger/Break /USART2 TX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler, 19)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
TIM2_ClearITPendingBit(TIM2_IT_Update);
if (tos_knl_is_running()) {
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
#ifdef USE_STM8L1528_EVAL
/* Write one byte to the transmit data register */
USART_SendData8(EVAL_COM1, TxBuffer[TxCounter++]);
USART_ClearITPendingBit(EVAL_COM1, USART_IT_TC);
if (TxCounter == TX_BUFFER_SIZE)
{
/* Disable the USART Transmit Complete interrupt */
USART_ITConfig(EVAL_COM1, USART_IT_TC, DISABLE);
}
#endif /* USE_STM8L1528_EVAL */
}
/**
* @brief Timer2 Capture/Compare / USART2 RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_CC_USART2_RX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
#ifdef USE_STM8L1528_EVAL
uint8_t temp;
/* Read one byte from the receive data register and send it back */
temp = (USART_ReceiveData8(EVAL_COM1) & 0x7F);
USART_SendData8(EVAL_COM1, temp);
#endif /* USE_STM8L1528_EVAL */
}
/**
* @brief Timer3 Update/Overflow/Trigger/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_UPD_OVF_TRG_BRK_USART3_TX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer3 Capture/Compare /USART3 RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_CC_USART3_RX_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief TIM1 Update/Overflow/Trigger/Commutation Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_COM_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief TIM1 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_CC_IRQHandler, 24)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief TIM4 Update/Overflow/Trigger Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief SPI1 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI1_IRQHandler, 26)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief USART1 TX / TIM5 Update/Overflow/Trigger/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(USART1_TX_TIM5_UPD_OVF_TRG_BRK_IRQHandler, 27)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
#ifdef USE_STM8L1526_EVAL
/* Write one byte to the transmit data register */
USART_SendData8(EVAL_COM1, TxBuffer[TxCounter++]);
USART_ClearITPendingBit(EVAL_COM1, USART_IT_TC);
if (TxCounter == TX_BUFFER_SIZE)
{
/* Disable the USART Transmit Complete interrupt */
USART_ITConfig(EVAL_COM1, USART_IT_TC, DISABLE);
}
#endif /* USE_STM8L1526_EVAL */
}
/**
* @brief USART1 RX / Timer5 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(USART1_RX_TIM5_CC_IRQHandler, 28)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
uint8_t data;
tos_knl_irq_enter();
if (USART_GetITStatus(USART1, USART_IT_RXNE)) {
data = USART_ReceiveData8(USART1);
tos_shell_input_byte(data);
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
tos_knl_irq_leave();
#ifdef USE_STM8L1526_EVAL
uint8_t temp;
/* Read one byte from the receive data register and send it back */
temp = (USART_ReceiveData8(EVAL_COM1) & 0x7F);
USART_SendData8(EVAL_COM1, temp);
#endif /* USE_STM8L1526_EVAL */
}
/**
* @brief I2C1 / SPI2 Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(I2C1_SPI2_IRQHandler, 29)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -82,7 +82,7 @@ __STATIC__ void shell_cmd_process(void)
static char *argv[SHELL_CMD_ARGV_MAX];
char *pos = SHELL_CTL->cmd_buffer;
printf("%s\n", pos);
tos_shell_printf("%s\n", SHELL_CTL->cmd_buffer);
// left strip
while (*pos == ' ' || *pos == '\t') {

View File

@@ -1,7 +1,7 @@
#include "tos_shell.h"
#include "tos_hal.h"
#define CMD_LEN_MAX 128
#define CMD_LEN_MAX 25
char cmd_buf[CMD_LEN_MAX];
hal_uart_t shell_uart;