Import YEEP-144 library 1.2 sources

Source-only snapshot of the 1.2 release. Drivers/ (the vendored ST HAL and
CMSIS) is excluded at 173 MB; fetch it from STMicroelectronics/STM32CubeH5 to
build.
This commit is contained in:
2026-10-28 14:37:42 +00:00
commit 50e4ba8a07
56 changed files with 7718 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#ifndef __YEEP144_H
#define __YEEP144_H
#include "stm32h5xx_hal.h"
#define GPIO_MODE_OUTPUT GPIO_MODE_OUTPUT_PP
#define DEBUGUART 1
#define BLUETOOTHUART 2
#define UARTSEL DEBUGUART
// Public Function Prototypes
int YEEP144_Init(void);
void delayUS(uint32_t us);
void YEEP144_GPIO_Init(GPIO_TypeDef* port, uint32_t pins, uint32_t mode);
void YEEP144_GPIO_InitAdv(GPIO_TypeDef* port, uint32_t pins, uint32_t mode, uint32_t pull, uint32_t speed, uint32_t alternate);
#endif

View File

@@ -0,0 +1,8 @@
#ifndef __YEEP144_ADCPOT_H
#define __YEEP144_ADCPOT_H
void YEEP144_ADCPot_Init(void);
uint16_t YEEP144_ADCPot_GetPot1(void);
uint16_t YEEP144_ADCPot_GetPot2(void);
#endif

View File

@@ -0,0 +1,19 @@
#ifndef __YEEP144_BLUETOOTHUART_H
#define __YEEP144_BLUETOOTHUART_H
#include "stm32h5xx_hal.h"
#include "stm32h5xx_hal_uart.h"
// Structure for UART info
extern UART_HandleTypeDef huart2;
void YEEP144_BluetoothUART_Init(void);
int YEEP144_BluetoothUART_printf(const char * format, ...);
void YEEP144_BluetoothUART_EnableCharMatchIRQ(void);
void YEEP144_BluetoothUART_DisableCharMatchIRQ(void);
void YEEP144_BluetoothUART_SetCharMatch(char match);
void YEEP144_BluetoothUART_SetStatusDelimiter(char prefix, char postfix);
#endif

View File

@@ -0,0 +1,10 @@
#ifndef __YEEP144_BUZZER_H
#define __YEEP144_BUZZER_H
void YEEP144_Buzzer_Init(void);
void YEEP144_Buzzer_Tone(uint32_t freq, uint32_t duration);
void YEEP144_Buzzer_GoTone(uint32_t freq);
void YEEP144_Buzzer_NoTone(void);
void YEEP144_Buzzer_Daisy(void);
#endif

View File

@@ -0,0 +1,39 @@
#ifndef __YEEP144_DCMOTOR_H
#define __YEEP144_DCMOTOR_H
#include <stdint.h>
// Defines
#define DCMOTOR1 1
#define DCMOTOR2 2
#define DCMOTOR3 3
#define DCMOTOR4 4
#define DCMOTOR_STOP 0 // 0b00
#define DCMOTOR_CCW 1 // 0b01
#define DCMOTOR_CW 2 // 0b10
#define DCMOTOR_SHORTBRAKE 3 // 0b11
#define DCMOTOR_MIN_SPEED 0
#define DCMOTOR_MAX_SPEED 4095 // This corresponds to the Period of the timer
// Function prototypes
// Init functions
void YEEP144_DCMotor_Init(void);
void YEEP144_Encoder1_Init(void);
void YEEP144_Encoder2_Init(void);
void YEEP144_Encoder3_Init(void);
void YEEP144_Encoder4_Init(void);
// Motor functions
void YEEP144_DCMotor_SetSpeed(uint8_t motor, uint16_t speed);
void YEEP144_DCMotor_SetDirection(uint8_t motor, uint8_t direction);
// Encoder functions
uint16_t YEEP144_Encoder1_Get(void);
uint16_t YEEP144_Encoder2_Get(void);
uint16_t YEEP144_Encoder3_Get(void);
uint16_t YEEP144_Encoder4_Get(void);
#endif

View File

@@ -0,0 +1,17 @@
#ifndef __YEEP144_DEBUGUART_H
#define __YEEP144_DEBUGUART_H
#include "stm32h5xx_hal.h"
#include "stm32h5xx_hal_uart.h"
// Structure for UART info
extern UART_HandleTypeDef huart3;
void YEEP144_DebugUART_Init(void);
int YEEP144_DebugUART_printf(const char * format, ...);
void YEEP144_DebugUART_EnableCharMatchIRQ(void);
void YEEP144_DebugUART_DisableCharMatchIRQ(void);
void YEEP144_DebugUART_SetCharMatch(char match);
#endif

View File

@@ -0,0 +1,10 @@
#ifndef __YEEP144_GP2Y0E02B_H
#define __YEEP144_GP2Y0E02B_H
#define GP2Y0E02B_I2C_ADDR 0x80
#define GP2Y0E02B_SHIFT_REG_ADDR 0x35
#define GP2Y0E02B_DISTANCE_REG_ADDR 0x5E
float YEEP144_GP2Y0E02B_Read(void);
#endif

View File

@@ -0,0 +1,29 @@
#ifndef __YEEP144_HCSR04_H
#define __YEEP144_HCSR04_H
#include <stdint.h>
void YEEP144_Ultrasonic1_Init(void);
void YEEP144_Ultrasonic2_Init(void);
void YEEP144_Ultrasonic3_Init(void);
void YEEP144_Ultrasonic4_Init(void);
uint8_t YEEP144_Ultrasonic_PingNext(void);
float YEEP144_Ultrasonic_TickTocm(uint16_t ticks);
uint8_t YEEP144_Ultrasonic1_Ping(void);
uint8_t YEEP144_Ultrasonic2_Ping(void);
uint8_t YEEP144_Ultrasonic3_Ping(void);
uint8_t YEEP144_Ultrasonic4_Ping(void);
uint16_t YEEP144_Ultrasonic1_PingBlocking(void);
uint16_t YEEP144_Ultrasonic2_PingBlocking(void);
uint16_t YEEP144_Ultrasonic3_PingBlocking(void);
uint16_t YEEP144_Ultrasonic4_PingBlocking(void);
void YEEP144_Ultrasonic_EXTI10Handler(void);
void YEEP144_Ultrasonic_EXTI12Handler(void);
extern uint16_t ultrasonicTickLen[4];
#endif

View File

@@ -0,0 +1,13 @@
#ifndef __YEEP144_I2C_H
#define __YEEP144_I2C_H
#include "stm32h5xx_hal.h"
#define I2C_MUX_ADDR 0xEE
extern I2C_HandleTypeDef hi2c2;
void YEEP144_I2C_Init(void);
void YEEP144_I2C_MuxSelect(uint8_t busNumber);
#endif

View File

@@ -0,0 +1,18 @@
#ifndef __YEEP144_PISPI_H
#define __YEEP144_PISPI_H
// This value define the size of the transfer buffers.
// It needs to match what is set on the Pi side so the correct amount of data is transferred each time
#define PISPI_BUFFER_SIZE 256
// Extern the buffer arrays so they are accessible from other files
extern uint8_t PiSPIRxBuf[PISPI_BUFFER_SIZE];
extern uint8_t PiSPITxBuf[PISPI_BUFFER_SIZE];
void YEEP144_PiSPI_Init(void);
void YEEP144_PiSPI_SetReady(void);
void YEEP144_PiSPI_ResetReady(void);
void YEEP144_PiSPI_LoadTx(void);
void YEEP144_PiSPI_TxRxHandler(void);
#endif

View File

@@ -0,0 +1,190 @@
/**
* This file contains #defines for the ports and pins used by the EEP-144 functions
* and is shared by all modules
*/
#ifndef __YEEP144_PINOUT_H
#define __YEEP144_PINOUT_H
// DC Motors
#define MOT1A_PORT GPIOG
#define MOT1A_PIN GPIO_PIN_0
#define MOT1B_PORT GPIOG
#define MOT1B_PIN GPIO_PIN_1
#define MOT1PWM_PORT GPIOC
#define MOT1PWM_PIN GPIO_PIN_6
#define MOT2A_PORT GPIOG
#define MOT2A_PIN GPIO_PIN_2
#define MOT2B_PORT GPIOG
#define MOT2B_PIN GPIO_PIN_3
#define MOT2PWM_PORT GPIOC
#define MOT2PWM_PIN GPIO_PIN_7
#define MOT3A_PORT GPIOE
#define MOT3A_PIN GPIO_PIN_7
#define MOT3B_PORT GPIOE
#define MOT3B_PIN GPIO_PIN_8
#define MOT3PWM_PORT GPIOB
#define MOT3PWM_PIN GPIO_PIN_0
#define MOT4A_PORT GPIOB
#define MOT4A_PIN GPIO_PIN_2
#define MOT4B_PORT GPIOB
#define MOT4B_PIN GPIO_PIN_4
#define MOT4PWM_PORT GPIOC
#define MOT4PWM_PIN GPIO_PIN_9
// DC Motor Encoders
#define ENC1A_PORT GPIOD
#define ENC1A_PIN GPIO_PIN_12
#define ENC1B_PORT GPIOD
#define ENC1B_PIN GPIO_PIN_13
#define ENC2A_PORT GPIOC
#define ENC2A_PIN GPIO_PIN_11
#define ENC2B_PORT GPIOA
#define ENC2B_PIN GPIO_PIN_15
#define ENC3A_PORT GPIOF
#define ENC3A_PIN GPIO_PIN_2
#define ENC3B_PORT GPIOF
#define ENC3B_PIN GPIO_PIN_9
#define ENC4A_PORT GPIOB
#define ENC4A_PIN GPIO_PIN_10
#define ENC4B_PORT GPIOD
#define ENC4B_PIN GPIO_PIN_11
// Servos
#define SERVO1_PORT GPIOA
#define SERVO1_PIN GPIO_PIN_0
#define SERVO2_PORT GPIOA
#define SERVO2_PIN GPIO_PIN_3
#define SERVO3_PORT GPIOF
#define SERVO3_PIN GPIO_PIN_8
#define SERVO4_PORT GPIOF
#define SERVO4_PIN GPIO_PIN_7
// Buzzer
#define BUZZER_PORT GPIOF
#define BUZZER_PIN GPIO_PIN_7
// UART
#define UART2_TX_PORT GPIOD
#define UART2_TX_PIN GPIO_PIN_5
#define UART2_RX_PORT GPIOD
#define UART2_RX_PIN GPIO_PIN_6
#define UART2_RTS_PORT GPIOD
#define UART2_RTS_PIN GPIO_PIN_4
#define UART2_CTS_PORT GPIOD
#define UART2_CTS_PIN GPIO_PIN_3
#define UART3_TX_PORT GPIOD
#define UART3_TX_PIN GPIO_PIN_9
#define UART3_RX_PORT GPIOD
#define UART3_RX_PIN GPIO_PIN_8
#define UART4_TX_PORT GPIOD
#define UART4_TX_PIN GPIO_PIN_1
#define UART4_RX_PORT GPIOD
#define UART4_RX_PIN GPIO_PIN_0
// I2C
#define I2C_SDA_PORT GPIOF
#define I2C_SDA_PIN GPIO_PIN_0
#define I2C_SCL_PORT GPIOF
#define I2C_SCL_PIN GPIO_PIN_1
// SPI
#define SPI_MISO_PORT GPIOE
#define SPI_MISO_PIN GPIO_PIN_5
#define SPI_MOSI_PORT GPIOE
#define SPI_MOSI_PIN GPIO_PIN_6
#define SPI_SCK_PORT GPIOE
#define SPI_SCK_PIN GPIO_PIN_12
#define SPI_CS_PORT GPIOE
#define SPI_CS_PIN GPIO_PIN_4
// Ultrasonic Distance Sensors
#define USONIC1_TRIG_PORT GPIOE
#define USONIC1_TRIG_PIN GPIO_PIN_0
#define USONIC1_ECHO_PORT GPIOC
#define USONIC1_ECHO_PIN GPIO_PIN_10
#define USONIC1_ECHO_EXTI EXTI10_IRQn
#define USONIC2_TRIG_PORT GPIOE
#define USONIC2_TRIG_PIN GPIO_PIN_2
#define USONIC2_ECHO_PORT GPIOG
#define USONIC2_ECHO_PIN GPIO_PIN_10
#define USONIC2_ECHO_EXTI EXTI10_IRQn
#define USONIC3_TRIG_PORT GPIOE
#define USONIC3_TRIG_PIN GPIO_PIN_3
#define USONIC3_ECHO_PORT GPIOE
#define USONIC3_ECHO_PIN GPIO_PIN_10
#define USONIC3_ECHO_EXTI EXTI10_IRQn
#define USONIC4_TRIG_PORT GPIOE
#define USONIC4_TRIG_PIN GPIO_PIN_15
#define USONIC4_ECHO_PORT GPIOF
#define USONIC4_ECHO_PIN GPIO_PIN_12
#define USONIC4_ECHO_EXTI EXTI12_IRQn
// Pushbuttons
#define BUTTON_BLUE_PORT GPIOC
#define BUTTON_BLUE_PIN GPIO_PIN_13
#define BUTTON_BLUE_EXTI EXTI13_IRQn
#define BUTTON_0_PORT GPIOC
#define BUTTON_0_PIN GPIO_PIN_13
#define BUTTON_0_EXTI EXTI13_IRQn
#define BUTTON_GREEN_PORT GPIOD
#define BUTTON_GREEN_PIN GPIO_PIN_7
#define BUTTON_GREEN_EXTI EXTI7_IRQn
#define BUTTON_1_PORT GPIOD
#define BUTTON_1_PIN GPIO_PIN_7
#define BUTTON_1_EXTI EXTI7_IRQn
#define BUTTON_YELLOW_PORT GPIOG
#define BUTTON_YELLOW_PIN GPIO_PIN_6
#define BUTTON_YELLOW_EXTI EXTI6_IRQn
#define BUTTON_2_PORT GPIOG
#define BUTTON_2_PIN GPIO_PIN_6
#define BUTTON_2_EXTI EXTI6_IRQn
#define BUTTON_RED_PORT GPIOB
#define BUTTON_RED_PIN GPIO_PIN_12
#define BUTTON_RED_EXTI EXTI12_IRQn
#define BUTTON_3_PORT GPIOB
#define BUTTON_3_PIN GPIO_PIN_12
#define BUTTON_3_EXTI EXTI12_IRQn
// Potentiometers
#define POT1_PORT GPIOF
#define POT1_PIN GPIO_PIN_13
#define POT2_PORT GPIOF
#define POT2_PIN GPIO_PIN_14
// SD Card
#define SD_CK_PORT GPIOC
#define SD_CK_PIN GPIO_PIN_12
#define SD_CMD_PORT GPIOD
#define SD_CMD_PIN GPIO_PIN_2
#define SD_D0_PORT GPIOC
#define SD_D0_PIN GPIO_PIN_8
// IR Beacon Receiver
#define IR_RECEIVER_PIN GPIO_PIN_3
#define IR_RECEIVER_PORT GPIOF
#define IR_RECEIVER_EXTI EXTI3_IRQn
#endif

View File

@@ -0,0 +1,14 @@
#ifndef __YEEP144_PUSHBUTTON_H
#define __YEEP144_PUSHBUTTON_H
void YEEP144_PushButton_BlueInit(void);
void YEEP144_PushButton_GreenInit(void);
void YEEP144_PushButton_YellowInit(void);
void YEEP144_PushButton_RedInit(void);
void YEEP144_PushButton_BlueHandler(void);
void YEEP144_PushButton_GreenHandler(void);
void YEEP144_PushButton_YellowHandler(void);
void YEEP144_PushButton_RedHandler(void);
#endif

View File

@@ -0,0 +1,91 @@
#ifndef __YEEP144_RGB_H
#define __YEEP144_RGB_H
#define RGB1_RED 0x5
#define RGB1_GREEN 0x4
#define RGB1_BLUE 0x6
#define RGB2_RED 0x8
#define RGB2_GREEN 0x7
#define RGB2_BLUE 0x9
#define RGB3_RED 0xB
#define RGB3_GREEN 0xA
#define RGB3_BLUE 0xC
#define RGB4_RED 0xE
#define RGB4_GREEN 0xD
#define RGB4_BLUE 0xF
// Pure colours
#define RGB_OFF 0x00, 0x00, 0x00
#define RGB_RED 0xFF, 0x00, 0x00
#define RGB_GREEN 0x00, 0x80, 0x00
#define RGB_BLUE 0x00, 0x00, 0x00
// HTML standard colours
#define RGB_WHITE 0xFF, 0xFF, 0xFF
#define RGB_MAROON 0x80, 0x00, 0x00
#define RGB_YELLOW 0xFF, 0xFF, 0xFF
#define RGB_OLIVE 0x80, 0x80, 0x00
#define RGB_LIME 0x00, 0xFF, 0x00
#define RGB_CYAN 0x00, 0xFF, 0xFF
#define RGB_TEAL 0x00, 0x80, 0x80
#define RGB_NAVY 0x00, 0x00, 0x80
#define RGB_MAGENTA 0xFF, 0x00, 0xFF
#define RGB_PURPLE 0x80, 0x00, 0x80
#define RGB_ORANGE 0xFF, 0xA5, 0x00
// Selection of HTML extended colours
// Pinks
#define RGB_DEEPPINK 0xFF, 0x14, 0x93
#define RGB_HOTPINK 0xFF, 0x69, 0xB4
#define RGB_PINK 0xFF, 0xC0, 0xCB
// Reds
#define RGB_DARKRED 0x8B, 0x00, 0x00
#define RGB_CRIMSON 0xDC, 0x14, 0x3C
#define RGB_SALMON 0xFA, 0x80, 0x72
// Oranges
#define RGB_ORANGERED 0xFF, 0x45, 0x00
#define RGB_DARKORANGE 0xFF, 0x8C, 0x00
#define RGB_CORAL 0xFF, 0x7F, 0x50
// Yellows
#define RGB_DARKKHAKI 0xBD, 0xB7, 0x6B
#define RGB_GOLD 0xFF, 0xD7, 0x00
#define RGB_KHAKI 0xF0, 0xE6, 0x8C
// Browns
#define RGB_BROWN 0xA5, 0x2A, 0x2A
#define RGB_SADDLEBROWN 0x8B, 0x45, 0x13
#define RGB_ROSYBROWN 0xBC, 0x8F, 0x8F
// Purples
#define RGB_INDIGO 0x4B, 0x00, 0x82
#define RGB_DARKORCHID 0x99, 0x32, 0xCC
#define RGB_VIOLET 0xEE, 0x82, 0xEE
// Blues
#define RGB_ROYALBLUE 0x41, 0x69, 0xE1
#define RGB_CORNFLOWERBLUE 0x64, 0x95, 0xED
#define RGB_SKYBLUE 0x87, 0xCE, 0xEB
// Cyans
#define RGB_TURQUOISE 0x40, 0xE0, 0xD0
#define RGB_AQUAMARINE 0x7F, 0xFF, 0xD4
// Greens
#define RGB_DARKGREEN 0x00, 0x64, 0x00
#define RGB_SEAGREEN 0x2E, 0x8B, 0x57
#define RGB_CHARTREUSE 0x7F, 0xFF, 0x00
void YEEP144_RGB_Init(void);
void YEEP144_RGB_SetLED(uint8_t led, uint8_t value);
void YEEP144_RGB_SetRGB(uint8_t led, uint8_t red, uint8_t green, uint8_t blue);
void YEEP144_RGB_WriteReg(uint16_t reg, uint8_t data);
#endif

View File

@@ -0,0 +1,35 @@
#ifndef __YEEP144_SSD1306_H
#define __YEEP144_SSD1306_H
#define SSD1306_BLACK 0
#define SSD1306_WHITE 1
#define SSD1306_INVERSE 2
#include <stdbool.h>
#include <stdarg.h>
void YEEP144_SSD1306_Init(void);
void YEEP144_SSD1306_Display(void);
void YEEP144_SSD1306_ClearDisplay(void);
void YEEP144_SSD1306_SetPixel(uint8_t x, uint8_t y, uint8_t colour);
bool YEEP144_SSD1306_GetPixel(uint8_t x, uint8_t y);
void YEEP144_SSD1306_DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t colour);
void YEEP144_SSD1306_DrawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t colour);
void YEEP144_SSD1306_DrawFillRect(uint8_t x, uint8_t y, int8_t w, int8_t h, uint8_t colour);
void YEEP144_SSD1306_DrawChar(uint8_t x, uint8_t y, uint8_t c, uint8_t colour, uint8_t bg, uint8_t size);
int YEEP144_SSD1306_printf(const char * format, ...);
void YEEP144_SSD1306_SetTextSize(uint8_t size);
void YEEP144_SSD1306_SetTextCursor(uint8_t x, uint8_t y);
void YEEP144_SSD1306_SetTextWrap(uint8_t wrap);
void YEEP144_SSD1306_DrawBitmap(uint8_t x, uint8_t y, const uint8_t bitmap[], uint8_t w, uint8_t h);
void YEEP144_SSD1306_InvertDisplay(bool i);
void YEEP144_SSD1306_SendCommand(uint8_t command);
extern const unsigned char UOYLogo[];
#endif

View File

@@ -0,0 +1,24 @@
#ifndef __YEEP144_SERVO_H
#define __YEEP144_SERVO_H
void YEEP144_Servo_Init1_2(void);
void YEEP144_Servo_Init3(void);
void YEEP144_Servo_Init4(void);
void YEEP144_Servo1_SetDirect(uint16_t pulse);
void YEEP144_Servo2_SetDirect(uint16_t pulse);
void YEEP144_Servo3_SetDirect(uint16_t pulse);
void YEEP144_Servo4_SetDirect(uint16_t pulse);
void YEEP144_Servo1_SetAngle(float angle);
void YEEP144_Servo2_SetAngle(float angle);
void YEEP144_Servo3_SetAngle(float angle);
void YEEP144_Servo4_SetAngle(float angle);
void YEEP144_Servo_SetMinTicks(uint8_t servo, uint16_t min);
void YEEP144_Servo_SetMaxTicks(uint8_t servo, uint16_t max);
void YEEP144_Servo_SetMinAngle(uint8_t servo, float min);
void YEEP144_Servo_SetMaxAngle(uint8_t servo, float max);
#endif

View File

@@ -0,0 +1,8 @@
#ifndef __YEEP144_TSOP4838_H
#define __YEEP144_TSOP4838_H
void YEEP144_TSOP4838_Init(void);
uint8_t YEEP144_TSOP4838_Received(void);
uint32_t YEEP144_TSOP4838_Read(void);
#endif