1
0
forked from me/IronOS

Split I2C + startup logo

This commit is contained in:
Ben V. Brown
2020-05-29 23:07:59 +10:00
parent d2dacf990c
commit a32e245789
6 changed files with 45 additions and 27 deletions

View File

@@ -41,6 +41,10 @@ void unstick_I2C();
//Reboot the IC when things go seriously wrong
void reboot();
//If the user has programmed in a bootup logo, draw it to the screen from flash
//Returns 1 if the logo was printed so that the unit waits for the timeout or button
uint8_t showBootLogoIfavailable();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,27 @@
/*
* logo.c
*
* Created on: 29 May 2020
* Author: Ralim
*/
#include "BSP.h"
#include "OLED.hpp"
// Second last page of flash set aside for logo image.
#define FLASH_LOGOADDR (0x8000000 | 0xF800)
// Logo header signature.
#define LOGO_HEADER_VALUE 0xF00DAA55
uint8_t showBootLogoIfavailable() {
// Do not show logo data if signature is not found.
if (LOGO_HEADER_VALUE
!= *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
return 0;
}
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
OLED::refresh();
return 1;
}

View File

@@ -8,12 +8,15 @@
#include "BSP.h"
#include "Setup.h"
#include "Pins.h"
#include "FRTosI2C.hpp"
void preRToSInit() {
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
*/
HAL_Init();
Setup_HAL(); // Setup all the HAL objects
FRToSI2C::init(&hi2c1);
HAL_Delay(50);
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(50);
}