SBB Micro
Source code for the self-balancing-bike microcontroller unit (Teensy 4.1-based). 🚀️
|
User-defined functions. More...
Functions | |
float | tempmonGetTemp (void) |
Get the CPU temperature. | |
uint32_t | set_arm_clock (uint32_t frequency) |
Set the CPU clock. | |
void | start_IObus (void) |
Initialize the IO buses. | |
void | set_IObus (void) |
Start the IO buses. | |
void | do_zeros (void) |
Perform the zero. | |
void | set_GPIO (void) |
Set the GPIO. | |
void | start_brake_stepper (void) |
Start the brake stepper motor. | |
void | get_sensors (void) |
Get sensor readings. | |
void | set_ctrl_input (void) |
Set the control inputs. | |
void | do_control (void) |
Update the control loop. | |
void | check_error (void) |
Check for errors. | |
bool | check_sbus (void) |
Check for SBUS. | |
void | set_driver (void) |
Set the drivers. | |
int8_t | get_selector (void) |
Get the selector. | |
bool | get_enable (void) |
Get the enable. | |
void | turnoff_callback (void) |
Callback for tuning off. | |
boolean | check_voltage (void) |
Check the battery voltage. | |
time_t | getTime () |
Get internal RTC time. | |
void | do_led () |
Management of the status LED. | |
void | serial_flush () |
Flush the UARTs. | |
void | set_ctrl_param () |
Set custom control parameters. | |
void | update_tet (uint32_t t0) |
Update task execution time. | |
User-defined functions.
Definition of the user defined functions called in main().
void check_error | ( | void | ) |
Check for errors.
Function to check for possible errors, such as unfeasible values of signals or limit exceeding. A error state variable is modified if errors are found.
bool check_sbus | ( | void | ) |
boolean check_voltage | ( | void | ) |
Check the battery voltage.
Function to check possible under- or over-voltage of the battery.
void do_control | ( | void | ) |
Update the control loop.
Function to update the control loop with the new sensor readings or create the ouput in the case of tests.
void do_led | ( | ) |
Management of the status LED.
Function to manage the status LED according to the microcontroller mode. Depending on the LED blinking, the microcontroller mode is:
void do_zeros | ( | void | ) |
Perform the zero.
Function to perform the zero-calibration of some sensors. These include the torsiometer, the actual motor current and the actual steer rate. It also sets the pre-defined offsets (e.g. for the gyrometer).
bool get_enable | ( | void | ) |
Get the enable.
Function to get the enable status. Enable is 0 if errors found or remote enable is off.
int8_t get_selector | ( | void | ) |
Get the selector.
Function to get the selector status. Selector is +/-1/0 depending on the switch on the remote controller.
void get_sensors | ( | void | ) |
Get sensor readings.
Function to get the sensor readings (raw values only). Sensors are read with the specified sampling factor.
time_t getTime | ( | ) |
Get internal RTC time.
Function to get the internal RTC time of the microcontroller.
void serial_flush | ( | ) |
uint32_t set_arm_clock | ( | uint32_t | frequency | ) |
Set the CPU clock.
Extern function to set the CPU clock.
frequency | The CPU clock in Hz. |
void set_ctrl_input | ( | void | ) |
Set the control inputs.
Function to convert sensor readings to convenient units.
void set_ctrl_param | ( | ) |
Set custom control parameters.
Function to set custom control parameters in controlParams, e.g. controlParams.propGainSpeed = 0.
void set_driver | ( | void | ) |
Set the drivers.
Function to set the drivers, such as the steer-motor driver and the throttle via the DAC. Drivers are set only if no error is found.
void set_GPIO | ( | void | ) |
Set the GPIO.
Function to set general-purpose input-output digital pins, depending on their usage. This also includes the assignment of a default (initial) state for the digital output pins.
void set_IObus | ( | void | ) |
Start the IO buses.
Function to start the IO buses for the sensors and drivers after initialization. This incluses the setting of sensors (IMU, magnetometer, GPS, ADC, PWM and DAC).
void start_brake_stepper | ( | void | ) |
Start the brake stepper motor.
Function to start and set the stepper motor acting on the brake lever.
void start_IObus | ( | void | ) |
Initialize the IO buses.
Function to initialize the IO buses for the sensors and drivers. This incluses initialization of SPI and the related sensors (IMU, magnetometer, and DAC), initialization of the UARTs for the speed sensor and GPS.
|
extern |
Get the CPU temperature.
Extern function to get the CPU temperature in Celsius degrees.
void turnoff_callback | ( | void | ) |
Callback for tuning off.
Callback function called when the microcontroller turns of, in order to end stuff before (e.g. close the log file).
void update_tet | ( | uint32_t | t0 | ) |
Update task execution time.
Function to update the TET.
t0 | The initial task time. |