Comments (2)
For the actual HAL code, I think it would be better to build a single shared library and then link against it from each board's BSP, and only generate a header file containing info about what peripheral is at what address. I don't really like the idea of generating actual library source code, since then we'd lose good IDE support on editing the library implementations.
To deal with differing hardware revisions, we should probably #ifdef
hardware-specific portions and set configuration flags during compilation.
from baremetal-ide-bsp.
I think a valid approach is this:
under /bsp/common
, we store the files for common periphery devices, like CORE, UART, GPIO etc.. If the SoC has custom periphery devices, it will be stored under /bsp/<chipname>
, but still with name hal_<peripheryname>.h
and hal_<peripheryname>.h
.
For the main hal.h
and hal.c
, it should be moved into user program, under /core
. Reasons being:
- In
hal.h
we will define settings like the system clock frequency, clock tree muxes etc. This is application-dependent, and therefore should be controlled by user. - The
HAL_init()
routine will also differ by chips, and therefore should be put in/core/hal.c
, and user can modify the init routine. hal.h
controls which peripheral devices are included in the final program. To reduce code size, user can exclude the code for unused periphery devices.
As a result, in /core/inc/main.h
, user will do
#include "hal.h"
and in /core/inc/hal.h
, it will be
#include "<chipname>.h"
#include "hal_core.h"
#include "hal_clint.h"
#include "hal_gpio.h"
#include "hal_i2c.h"
...
#define HXTAL_FREQ 20000000 // Hz
// #define HXTAL_FREQ 100000000 // Hz
#define SYS_CLK_FREQ HXTAL_FREQ / 2 // Hz
#define MTIME_FREQ (SYS_CLK_FREQ / 100000) // tick per milliseconds
from baremetal-ide-bsp.
Related Issues (7)
- Multihart program only runs when JTAG connects to the corresponding hart
- Naming Convension Violation
- about adding BSP rules for a customized heterogeneous SoC from chipyard
- getTick should read from CSR directly instead of CLINT for minimal overhead
- ECALL exception when main() returns
- this code seems sus HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baremetal-ide-bsp.