Difference between revisions of "Oresat-notes"
From Wiki at Neela Nurseries
m |
m |
||
Line 15: | Line 15: | ||
* https://www.playembedded.org/blog/stm32-i2c-chibios/ | * https://www.playembedded.org/blog/stm32-i2c-chibios/ | ||
+ | |||
+ | |||
+ | Example file which calls an I2C init function among other things, in routine app_init(): | ||
+ | |||
+ | oresat-firmware/src$ vi ./archive/f0/app_solardemo/main.c | ||
+ | |||
+ | <pre> | ||
+ | |||
+ | /* | ||
+ | * I2C configuration | ||
+ | */ | ||
+ | static const I2CConfig i2cfg1 = | ||
+ | { | ||
+ | I2C_100KHZ_TIMINGR, | ||
+ | 0, | ||
+ | 0, | ||
+ | }; | ||
+ | |||
+ | uint8_t data[8]; | ||
+ | |||
+ | static void app_init(void) { | ||
+ | //=== App initialization | ||
+ | |||
+ | // Start up debug output | ||
+ | sdStart(&SD2, &ser_cfg); | ||
+ | |||
+ | i2cInit(); | ||
+ | i2cStart(&I2CD1, &i2cfg1); | ||
+ | |||
+ | for (uint8_t i = 0; i < 8; ++i) { | ||
+ | data[i] = 0; | ||
+ | } | ||
+ | |||
+ | canTPDOObjectInit(CAN_PDO_1, CAN_ID_DEFAULT, 0, 0, 8, data); | ||
+ | } | ||
+ | </pre> | ||
<!-- comment --> | <!-- comment --> |
Revision as of 06:12, 5 February 2021
Note) Looks like a command shell is realized in code near end of file:
psas/oresat-firmware/src/f4/app_control/source/command.c
Note) ina226.c and other device type driver source files in 'psas/oresat-firmware/common' give examples of I2C calls in ChibiOS environment.
INA226_SHARED_I2C
References:
* https://www.playembedded.org/blog/stm32-i2c-chibios/
Example file which calls an I2C init function among other things, in routine app_init():
oresat-firmware/src$ vi ./archive/f0/app_solardemo/main.c
/* * I2C configuration */ static const I2CConfig i2cfg1 = { I2C_100KHZ_TIMINGR, 0, 0, }; uint8_t data[8]; static void app_init(void) { //=== App initialization // Start up debug output sdStart(&SD2, &ser_cfg); i2cInit(); i2cStart(&I2CD1, &i2cfg1); for (uint8_t i = 0; i < 8; ++i) { data[i] = 0; } canTPDOObjectInit(CAN_PDO_1, CAN_ID_DEFAULT, 0, 0, 8, data); }