QOL fixes, compatibility fixes, attribution
This commit is contained in:
parent
bc7ba33892
commit
1f42ce5f40
|
@ -46,7 +46,10 @@ void run_background_tasks(void) {
|
|||
}
|
||||
running_background_tasks = true;
|
||||
filesystem_background();
|
||||
|
||||
#if USB_AVAILABLE
|
||||
usb_background();
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_DISPLAYIO
|
||||
displayio_refresh_displays();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -36,6 +37,8 @@ I2C_HandleTypeDef hi2c2;
|
|||
|
||||
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
||||
const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) {
|
||||
//TODO: Rework this entire section to use LL, alongside MSP removal
|
||||
|
||||
hi2c2.Instance = I2C1;
|
||||
hi2c2.Init.ClockSpeed = 100000;
|
||||
hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -40,6 +40,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) {
|
|||
}
|
||||
|
||||
bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Dan Halbert for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -25,3 +25,4 @@
|
|||
*/
|
||||
|
||||
void stm32f4_peripherals_gpio_init(void);
|
||||
void stm32f4_peripherals_status_led(uint8_t led, uint8_t state);
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
#define LD6_GPIO_Port GPIOD
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
|
||||
void stm32f4_peripherals_gpio_init(void) {
|
||||
//Enable all GPIO for now
|
||||
|
@ -128,10 +129,26 @@ void stm32f4_peripherals_gpio_init(void) {
|
|||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
//Status LED chain
|
||||
HAL_GPIO_WritePin(GPIOD, LD4_Pin, GPIO_PIN_RESET); //LED 1
|
||||
HAL_GPIO_WritePin(GPIOD, LD3_Pin, GPIO_PIN_SET); //LED 2
|
||||
HAL_GPIO_WritePin(GPIOD, LD5_Pin, GPIO_PIN_SET); //LED 3
|
||||
HAL_GPIO_WritePin(GPIOD, LD6_Pin, GPIO_PIN_SET); //LED 4
|
||||
stm32f4_peripherals_status_led(0,1);
|
||||
stm32f4_peripherals_status_led(1,0);
|
||||
stm32f4_peripherals_status_led(2,0);
|
||||
stm32f4_peripherals_status_led(3,0);
|
||||
}
|
||||
|
||||
//LEDs are inverted on F411 DISCO
|
||||
void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) {
|
||||
switch(led)
|
||||
{
|
||||
case 0: HAL_GPIO_WritePin(GPIOD, LD4_Pin, (state ^ 1));
|
||||
break;
|
||||
case 1: HAL_GPIO_WritePin(GPIOD, LD3_Pin, (state ^ 1));
|
||||
break;
|
||||
case 2: HAL_GPIO_WritePin(GPIOD, LD5_Pin, (state ^ 1));
|
||||
break;
|
||||
case 3: HAL_GPIO_WritePin(GPIOD, LD6_Pin, (state ^ 1));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@
|
|||
*/
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
|
||||
void stm32f4_peripherals_gpio_init(void) {
|
||||
//Enable all GPIO for now
|
||||
|
@ -202,17 +203,26 @@ void stm32f4_peripherals_gpio_init(void) {
|
|||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
//Status LED chain
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, GPIO_PIN_RESET); //LED 1
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET); //LED 2
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET); //LED 3
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET); //LED 4
|
||||
stm32f4_peripherals_status_led(0,1);
|
||||
stm32f4_peripherals_status_led(1,0);
|
||||
stm32f4_peripherals_status_led(2,0);
|
||||
stm32f4_peripherals_status_led(3,0);
|
||||
}
|
||||
|
||||
//TBD, USB power
|
||||
// GPIO_InitStruct.Pin = USB_OTGFS_PPWR_EN_Pin;
|
||||
// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
||||
// GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
// HAL_GPIO_Init(USB_OTGFS_PPWR_EN_GPIO_Port, &GPIO_InitStruct);
|
||||
//LEDs are inverted on F411 DISCO
|
||||
void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) {
|
||||
switch(led)
|
||||
{
|
||||
case 0: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, (state ^ 1));
|
||||
break;
|
||||
case 1: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, (state ^ 1));
|
||||
break;
|
||||
case 2: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, (state ^ 1));
|
||||
break;
|
||||
case 3: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, (state ^ 1));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -67,8 +68,8 @@ static uint8_t sector_copy[0x4000] __attribute__((aligned(4)));
|
|||
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
|
||||
if (addr >= flash_layout[0].base_address) {
|
||||
uint32_t sector_index = 0;
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) {
|
||||
for (int j = 0; j < flash_layout[i].sector_count; ++j) {
|
||||
for (uint8_t i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) {
|
||||
for (uint8_t j = 0; j < flash_layout[i].sector_count; ++j) {
|
||||
uint32_t sector_start_next = flash_layout[i].base_address
|
||||
+ (j + 1) * flash_layout[i].sector_size;
|
||||
if (addr < sector_start_next) {
|
||||
|
@ -112,7 +113,7 @@ static int32_t convert_block_to_flash_addr(uint32_t block) {
|
|||
}
|
||||
|
||||
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
|
||||
uint32_t src = convert_block_to_flash_addr(block);
|
||||
int32_t src = convert_block_to_flash_addr(block);
|
||||
if (src == -1) {
|
||||
// bad block number
|
||||
return false;
|
||||
|
@ -172,7 +173,7 @@ bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) {
|
|||
__HAL_FLASH_DATA_CACHE_ENABLE();
|
||||
|
||||
// reprogram the sector
|
||||
for (int i = 0; i < sector_size; i++) {
|
||||
for (uint32_t i = 0; i < sector_size; i++) {
|
||||
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, sector_start_addr, (uint64_t)sector_copy[i]) != HAL_OK) {
|
||||
// error occurred during flash write
|
||||
HAL_FLASH_Lock(); // lock the flash
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -28,6 +29,7 @@
|
|||
#include <string.h>
|
||||
#include "supervisor/serial.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
|
||||
UART_HandleTypeDef huart2;
|
||||
|
||||
|
@ -42,10 +44,8 @@ void serial_init(void) {
|
|||
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
if (HAL_UART_Init(&huart2) == HAL_OK)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||
stm32f4_peripherals_status_led(1,1);
|
||||
}
|
||||
HAL_UART_Transmit(&huart2, (uint8_t*)"Serial On", 9, 2);
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
bool serial_connected(void) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 hathach for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -107,11 +107,9 @@
|
|||
// USB RAM PLACEMENT
|
||||
//--------------------------------------------------------------------+
|
||||
#define CFG_TUSB_ATTR_USBRAM
|
||||
|
||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue