This C-library contains hardware abstraction layer (HAL) for STC15W408AS.
STC15W408AS is a micro chip compatible with 8051 architecture.
This code is published as Platformio library named STC15 hardware.
After create Platformio project for STC15408AS add to platformio.ini line with library depandency
[env:STC15W408AS]
platform = intel_mcs51
board = STC15W408AS
lib_deps = mgoblin/STC15 hardware@^0.8.0
Where is 0.7.0 STC15 hardware library version.
As alternative in lib_deps line github link could be used.
[env:STC15W408AS]
platform = intel_mcs51
board = STC15W408AS
lib_deps = https://github.com/mgoblin/STC15lib#0.8.0
Where is 0.8.0 STC15 hardware library github tag version.
Each released library version has the tag in github repository.
You can directly manipulate to MCU registers from C-code. STC15Fxx.h should be included.
#include <STC15Fxx.h> // MCU SFR declarations
void main()
{
// Use SFR declaration to change MCU state here
P10 = 0; // As example put LED on. Pin P1.0 connected to onboard LED
}
This library provides hardware astraction laywer (HAL) for high level development tasks. Please read the docs for library modules in Library documentation section (see the docs link).
Most of HAL functionality is C-macros.
The advantage is small firmware code size because macroses are expanded into application.
C-Macroses have some drawbacks.
- No compiler typechecks
- No function call optimizations. Macroses code inlined.
If you need to use one HAL macros many times the good idea is to wrap macros by C-function.
#include <delay.h>
#define LED P10
#define ON 0
#define OFF 1
// Wrap delay_ms HAL macros call to C-function
void f_delay_ms(uint16_t ms)
{
delay_ms(ms); // This is a macros
}
void main()
{
while(1)
{
LED = ON;
f_delay_ms(500);
LED = OFF;
f_delay_ms(1000);
}
}
Module name | Description | Maturity |
---|---|---|
ChipID | Get chip id from ROM | READY |
Delay | CPU cycles based delay | READY |
CPU frequency | CPU frequency slowdown | READY |
Interrupt | Enable and disable interrupts | READY |
Power management | idle, powerdown and wakeup timer | READY |
Reset | Software reset | READY |
Timer | Timer control routines | READY |
UART | Serial port routines | INITIAL SUPPORT |
Watchdog timer | Watchdog timer routines | READY |
Pin | Pin as digital in/out routines | READY |
Other modules does not implemented yet.
See examples in https://github.com/mgoblin/STC15lib/tree/main/examples
- STC datasheets: http://stcmicro.com/sjsc.html
- SDCC User Guide (PDF): http://sdcc.sourceforge.net/doc/sdccman.pdf
- STC programmator https://github.com/mgoblin/STC-programmatorhttps://github.com/mgoblin/STC-programmator