gicking / stm8_headers Goto Github PK
View Code? Open in Web Editor NEWDevice headers and examples for STM8 microcontrollers
License: MIT License
Device headers and examples for STM8 microcontrollers
License: MIT License
First, this is really nice work, so legible. Thanks!
Reading through STM8SF103F3.h and comparing it to ST's RM0016 I think I found some inconsistancies.
Here it seems that the reset values for some of the ADC registers that have H and L parts are swapped. For example:
/** ADC high threshold register high (HTRH at 0x5408) */
union {
/// bytewise access to HTRH
uint8_t byte;
/// bitwise access to register HTRH
struct {
BITS HT : 8; // bits 0-7
}; // HTRH bitfield
/// register _ADC1_HTRH reset value
#define sfr_ADC1_HTRH_RESET_VALUE ((uint8_t) 0x03)
} HTRH;
/** ADC high threshold register low (HTRL at 0x5409) */
union {
/// bytewise access to HTRL
uint8_t byte;
/// bitwise access to register HTRL
struct {
BITS HT : 2; // bits 0-1
BITS : 6; // 6 bits
}; // HTRL bitfield
/// register _ADC1_HTRL reset value
#define sfr_ADC1_HTRL_RESET_VALUE ((uint8_t) 0xFF)
} HTRL;
It seems to me that sfr_ADC1_HTRH_RESET_VALUE is swapped with sfr_ADC1_HTRL_RESET_VALUE as the values done match the bit field sizes.
I did a quick check of other non-zero RESET_VALUEs and also found:
/** SPI Rx CRC register (RXCRCR at 0x5206) */
union {
/// bytewise access to RXCRCR
uint8_t byte;
/// bitwise access to register RXCRCR
struct {
BITS RXCRC : 8; // bits 0-7
}; // RXCRCR bitfield
/// register _SPI_RXCRCR reset value
#define sfr_SPI_RXCRCR_RESET_VALUE ((uint8_t) 0xFF)
} RXCRCR;
/** SPI Tx CRC register (TXCRCR at 0x5207) */
union {
/// bytewise access to TXCRCR
uint8_t byte;
/// bitwise access to register TXCRCR
struct {
BITS TXCRC : 8; // bits 0-7
}; // TXCRCR bitfield
/// register _SPI_TXCRCR reset value
#define sfr_SPI_TXCRCR_RESET_VALUE ((uint8_t) 0xFF)
} TXCRCR;
It seems likely that these don't really have sensible reset values, but according to RM00016 if they did, it would be 0x00, not 0xFF.
i am use this cmd (sdcc --Werror --std-sdcc99 -mstm8 -DSTM8S103F3 -c C:\Users\techs\Desktop\STM8s103F\main.c -o C:\Users\techs\Desktop\STM8s103F\Output/STM8s103F.o )
sdcpp.exe: fatal error: when writing output to : Invalid argument
include\STM8S103F3.h:1903: syntax error: token -> 'volatile' ; column 29
please healp me
I think these two lines are duplicates of later lines where the union does close properly. SDCC was giving errors on including the header file. I removed them nd was able to compile.
STM8_headers/include/STM8L151G6.h
Line 2554 in 13f3ecd
STM8_headers/include/STM8L151G6.h
Line 2512 in 13f3ecd
Some headers are missing many bitfield names which renders them quite unusable.
$ grep '^ BITFIELD_UINT' -R * | less
...
STM8S105K4.h: BITFIELD_UINT SWIMCLK : 1; // bit 0
STM8S105K4.h: BITFIELD_UINT : 7; // 7 bits
STM8S105K4.h: BITFIELD_UINT C : 1; // bit 0
STM8S105K4.h: BITFIELD_UINT Z : 1; // bit 1
STM8S105K4.h: BITFIELD_UINT NF : 1; // bit 2
STM8S105K4.h: BITFIELD_UINT I0 : 1; // bit 3
STM8S105K4.h: BITFIELD_UINT H : 1; // bit 4
STM8S105K4.h: BITFIELD_UINT I1 : 1; // bit 5
STM8S105K4.h: BITFIELD_UINT : 1; // 1 bit
STM8S105K4.h: BITFIELD_UINT V : 1; // bit 7
STM8S105K4.h: BITFIELD_UINT SWO : 1; // bit 0
STM8S105K4.h: BITFIELD_UINT AL : 1; // bit 1
STM8S105K4.h: BITFIELD_UINT : 6; // 6 bits
STM8S105K4.h: BITFIELD_UINT FIX : 1; // bit 0
STM8S105K4.h: BITFIELD_UINT IE : 1; // bit 1
STM8S105K4.h: BITFIELD_UINT AHALT : 1; // bit 2
STM8S105K4.h: BITFIELD_UINT HALT : 1; // bit 3
STM8S105K4.h: BITFIELD_UINT : 4; // 4 bits
STM8S105K4.h: BITFIELD_UINT PRG : 1; // bit 0
STM8S105K4.h: BITFIELD_UINT : 3; // 3 bits
STM8S105K4.h: BITFIELD_UINT FPRG : 1; // bit 4
...
What is the motivation for the BITS macro?
Wouldn't it work just as well, to just use unsigned int as type for for the bitfields, and not define the BITS macro at all? Especially since a name like BITS has a high risk of clashing with an identifier from the user?
This repository contains .svd, .sxml and .h files.
Over at SourceForge, there is a ticket for adding the headers to SDCC: https://sourceforge.net/p/sdcc/patches/367/
If SDCC would add the h files, would those be the preferred form for modification?
What is the relation between the svd, xml and h files? Which are generated from which using which tool? Which is the preferred form for making modifications?
You forgot to list the STM8S in the first introductory paragraph of the README file. Doesn't quite meet the definition of "all STM8 microcontrollers" if that isn't mentioned. ;-)
There currently is not header for the STLUX 385. AFAIK, ST replaced it by the STLUX385A, but the older STLUX385 is still widely available at distributors.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.