Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skhoroshavin/microhal
HAL for microcontrollers
https://github.com/skhoroshavin/microhal
Last synced: about 1 month ago
JSON representation
HAL for microcontrollers
- Host: GitHub
- URL: https://github.com/skhoroshavin/microhal
- Owner: skhoroshavin
- Created: 2014-11-03T16:15:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-11T15:17:32.000Z (almost 10 years ago)
- Last Synced: 2023-08-09T23:12:14.266Z (over 1 year ago)
- Language: JavaScript
- Size: 1.72 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.txt
Awesome Lists containing this project
README
Directory structure
===================src - Main source tree
platform - Platform dependent functions and build scripts
utils - Generic utilities
drivers - Device drivers, used indirectly through hal.h by any part of project
system - Operating system, depends on platform, utils and hal.h
demo - Demo project
arduino - Arduino HAL for demo projectUser project
============Makefile:
Define PLATFORM - platform name (AVR,STM32,NORDIC51,etc)
Define MCU - controller name
Define OSDIR - path to MicroOS
Define TARGET - binary name
Define SOURCES - list of used c files
Include core build.mk
Define flash target if necessaryProject must contain hal.h, because it is included in driver
implementationsDriver usage:
Put driver configuration macros in hal.h
Include driver.h in hal.h after these macros
Include driver.c in makefile source listInterfaces
==========GPIO
gpio_init() - initialize bus
gpio_write(value) - write value (for output bus)
gpio_read() - read value (for input bus)Timer
timer_freq - timer frequency
timer_value_t - timer value type
timer_init() - initialize timer
timer_start() - start timer
timer_stop() - stop timer
timer_value() - timer current value
timer_set_value(value) - set timer current valueTimer compare
compare_value()
compare_set_value()
compare_irq_enable()
compare_irq_disable()
compare_irq()UART
uart_init(baud) - initialize UART
uart_can_send() - check if UART is ready to send data
uart_can_recv() - check if UART is ready to receive data
uart_send(value) - send 1 byte
uart_recv() - receive 1 byteSystem
======
Clock configuration
clock_freq - clock frequencyClock secondary configuration
clock_prescale - clock_timer_freq/clock_freqClock (periodic)
clock_overflow_irq()
soft_irq_raiseI( clock_periodic )clock_soft_irq()
clock_timeout( dt )clock_set_timeout( value )
Clock (tickless)
clock_compare_irq()
soft_irq_raiseI( clock )clock_soft_irq()
calc dt
call clock_timeout( dt )
set next compare valueclock_set_timeout( value )
Static timers
volatile unsigned _delays[count];
extern FLASH(static_timer_func_t,_timers);static_timers_process(dt)
min_delay = max_delay
for each timer
if !delay
continue
if dt < delay
delay -= dt
min_delay = min( delay, min_delay )
continue
delay = timer_proc()
if delay
min_delay = min( delay, min_delay )
return min_delay