2017-05-30 15:38:51 -07:00
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2023-12-26 12:31:31 -08:00
|
|
|
#include "usbconsole.h"
|
2017-05-30 15:38:51 -07:00
|
|
|
#include "hardware.h"
|
|
|
|
|
2023-12-26 12:31:31 -08:00
|
|
|
extern "C" {
|
|
|
|
#include "boot.h"
|
|
|
|
#include "shared_params.h"
|
|
|
|
}
|
|
|
|
|
2024-02-01 13:28:43 -08:00
|
|
|
class BlinkyThread : public chibios_rt::BaseStaticThread<256> {
|
|
|
|
protected:
|
|
|
|
void main(void) override {
|
|
|
|
Gpio yellow = getWarningLedPin();
|
|
|
|
|
|
|
|
efiSetPadMode("yellow", yellow, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
|
|
|
|
auto yellowPort = getBrainPinPort(yellow);
|
|
|
|
auto yellowPin = getBrainPinIndex(yellow);
|
|
|
|
|
|
|
|
palSetPad(yellowPort, yellowPin);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
palTogglePad(yellowPort, yellowPin);
|
|
|
|
chThdSleepMilliseconds(250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static BlinkyThread blinky;
|
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
int main(void) {
|
|
|
|
halInit();
|
|
|
|
chSysInit();
|
2023-08-25 22:34:36 -07:00
|
|
|
|
2023-12-26 12:31:31 -08:00
|
|
|
baseMCUInit();
|
|
|
|
|
2024-02-01 13:28:43 -08:00
|
|
|
// start the blinky thread
|
|
|
|
blinky.start(NORMALPRIO + 10);
|
|
|
|
|
2023-12-26 12:31:31 -08:00
|
|
|
// Init openblt shared params
|
|
|
|
SharedParamsInit();
|
|
|
|
|
|
|
|
// Init openblt itself
|
|
|
|
BootInit();
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2023-08-25 22:34:36 -07:00
|
|
|
while (true) {
|
2023-12-26 12:31:31 -08:00
|
|
|
BootTask();
|
2023-08-25 22:34:36 -07:00
|
|
|
}
|
2017-05-30 15:38:51 -07:00
|
|
|
}
|
2023-12-26 12:31:31 -08:00
|
|
|
|
|
|
|
// very basic version, supports on chip pins only (really only used for USB)
|
|
|
|
void efiSetPadMode(const char* msg, brain_pin_e brainPin, iomode_t mode) {
|
|
|
|
ioportid_t port = getHwPort(msg, brainPin);
|
|
|
|
ioportmask_t pin = getHwPin(msg, brainPin);
|
|
|
|
/* paranoid */
|
|
|
|
if (port == GPIO_NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
palSetPadMode(port, pin, mode);
|
|
|
|
}
|