You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on some board, I can have same pin functionality but on different pins. Board A has a FAN output on PC7, while board B on PC6 and so on. Since pin numbers are hardcoded as a struct field, how can I declare which pin to use ? E.g. a separate file which defines all pins based on some feature (feature would be a board name and revision) to use.
This is simplified as it assumes all pins use GPIOC. Situation gets complicated when using different GPIO ports as well as CRH, CRL.
What I am used to (as I did some C/C++ embedded programming) and find most elegant solution:
#if defined(BOARD_A)
using FAN_PIN = GPIO::PC7;
#elif defined(BOARD_B)
using FAN_PIN = GPIO::PC6;
#else
error "Board not implemented"
#endif// Or include a hwconfig header file in which all ifdef's are.
#include"hwconfig.h"intmain() {
fan = GPIO::PIN(FAN_PIN);
}
The text was updated successfully, but these errors were encountered:
Hi.
Based on some board, I can have same pin functionality but on different pins. Board A has a FAN output on PC7, while board B on PC6 and so on. Since pin numbers are hardcoded as a struct field, how can I declare which pin to use ? E.g. a separate file which defines all pins based on some feature (feature would be a board name and revision) to use.
I'd like to avoid this situation:
This is simplified as it assumes all pins use GPIOC. Situation gets complicated when using different GPIO ports as well as CRH, CRL.
What I am used to (as I did some C/C++ embedded programming) and find most elegant solution:
The text was updated successfully, but these errors were encountered: