資源簡介
STM8新建IAR工程模版,本例程用的是STM8S003,很容易移植到其他系列,同時加入了簡單的串口代碼。

代碼片段和文件信息
#include?“debug.h“
#include?“stm8s.h“
#include?“uart.h“
#define?DEBUGEN??1
#ifdef?USE_STANDARD_PRINTF
??/**
??*?@brief?Retargets?the?C?library?printf?function?to?the?UART.
??*?@param?c?Character?to?send
??*?@retval?char?Character?sent
??*/
PUTCHAR_PROTOTYPE
{
??/*?Write?a?character?to?the?UART1?*/
??UART1_SendData8(c);
??/*?Loop?until?the?end?of?transmission?*/
??while?(UART1_GetFlagStatus(UART1_FLAG_TXE)?==?RESET);
??return?(c);
}
/**
??*?@brief?Retargets?the?C?library?scanf?function?to?the?USART.
??*?@param?None
??*?@retval?char?Character?to?Read
??*/
GETCHAR_PROTOTYPE
{
#ifdef?_COSMIC_
??char?c?=?0;
#else
??int?c?=?0;
#endif
??/*?Loop?until?the?Read?data?register?flag?is?SET?*/
??while?(UART1_GetFlagStatus(UART1_FLAG_RXNE)?==?RESET);
????c?=?UART1_ReceiveData8();
??return?(c);
}
#else
void?DebugPrintStr(const?char?*str)
{
??if(DEBUGEN)
??{
????UartSendString(str);
??}
}
#endif
#ifdef?USE_FULL_ASSERT
/**
??*?@brief??Reports?the?name?of?the?source?file?and?the?source?line?number
??*???where?the?assert_param?error?has?occurred.
??*?@param?file:?pointer?to?the?source?file?name
??*?@param?line:?assert_param?error?line?source?number
??*?@retval?None
??*/
void?assert_failed(uint8_t*?file?uint32_t?line)
{?
??/*?User?can?add?his?own?implementation?to?report?the?file?name?and?line?number
?????ex:?printf(“Wrong?parameters?value:?file?%s?on?line?%d\r\n“?file?line)?*/
??/*?Infinite?loop?*/
??while?(1)
??{
??}
}
#endif
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1518??2018-12-29?14:39??stm8-project\APP\debug.c
?????文件????????551??2018-12-29?14:40??stm8-project\APP\debug.h
?????文件????????371??2018-12-26?11:16??stm8-project\APP\delay.c
?????文件????????130??2018-12-26?11:09??stm8-project\APP\delay.h
?????文件???????1386??2019-01-04?10:27??stm8-project\APP\uart.c
?????文件????????255??2019-01-03?19:30??stm8-project\APP\uart.h
?????文件??????????3??2019-01-04?09:14??stm8-project\BuildLog.log
?????文件???????5770??2019-01-04?10:36??stm8-project\Debug\Exe\stm8.hex
?????文件??????70876??2019-01-04?10:36??stm8-project\Debug\Exe\stm8.out
?????文件??????19987??2019-01-04?10:36??stm8-project\Debug\List\stm8.map
?????文件???????6124??2019-01-04?10:36??stm8-project\Debug\Obj\debug.o
?????文件?????325047??2019-01-04?10:26??stm8-project\Debug\Obj\debug.pbi
?????文件??????11471??2019-01-04?10:26??stm8-project\Debug\Obj\debug.pbi.xcl
?????文件???????5538??2019-01-04?10:36??stm8-project\Debug\Obj\delay.o
?????文件????????963??2019-01-04?10:26??stm8-project\Debug\Obj\delay.pbi
?????文件??????11471??2019-01-04?10:26??stm8-project\Debug\Obj\delay.pbi.xcl
?????文件???????4827??2019-01-04?10:36??stm8-project\Debug\Obj\main.o
?????文件?????325545??2019-01-04?10:39??stm8-project\Debug\Obj\main.pbi
?????文件??????11471??2019-01-04?10:39??stm8-project\Debug\Obj\main.pbi.xcl
?????文件?????416714??2019-01-04?10:36??stm8-project\Debug\Obj\stm8.pbd
?????文件????????468??2019-01-04?10:36??stm8-project\Debug\Obj\stm8.pbd.linf
?????文件??????57283??2019-01-04?10:36??stm8-project\Debug\Obj\stm8s_clk.o
?????文件?????345481??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_clk.pbi
?????文件??????11498??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_clk.pbi.xcl
?????文件??????24165??2019-01-04?10:36??stm8-project\Debug\Obj\stm8s_gpio.o
?????文件?????328491??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_gpio.pbi
?????文件??????11499??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_gpio.pbi.xcl
?????文件??????33202??2019-01-04?10:36??stm8-project\Debug\Obj\stm8s_it.o
?????文件?????326993??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_it.pbi
?????文件??????11475??2019-01-04?10:26??stm8-project\Debug\Obj\stm8s_it.pbi.xcl
............此處省略92個文件信息
評論
共有 條評論