summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
commita52eb88031620a81521b937f2a0651dbac2bb350 (patch)
tree017cbf8f686b252241182ef61ce48e8457aa1577 /supervisor
parent090b6ba42fcdfbb16844f77892087f91aa6ea201 (diff)
run code formatting script
Diffstat (limited to 'supervisor')
-rw-r--r--[-rwxr-xr-x]supervisor/linker.h6
-rw-r--r--[-rwxr-xr-x]supervisor/memory.h12
-rw-r--r--supervisor/port.h2
-rw-r--r--supervisor/serial.h6
-rw-r--r--supervisor/shared/background_callback.c17
-rw-r--r--supervisor/shared/bluetooth.c108
-rw-r--r--supervisor/shared/board.c2
-rw-r--r--supervisor/shared/board.h2
-rw-r--r--supervisor/shared/display.c26
-rw-r--r--supervisor/shared/external_flash/devices.h994
-rw-r--r--supervisor/shared/external_flash/external_flash.c86
-rw-r--r--supervisor/shared/external_flash/external_flash_root_pointers.h2
-rw-r--r--supervisor/shared/external_flash/qspi_flash.c2
-rw-r--r--supervisor/shared/external_flash/qspi_flash.h2
-rw-r--r--supervisor/shared/external_flash/spi_flash.c21
-rw-r--r--supervisor/shared/filesystem.c8
-rw-r--r--supervisor/shared/flash.c2
-rw-r--r--[-rwxr-xr-x]supervisor/shared/memory.c126
-rw-r--r--supervisor/shared/micropython.c2
-rw-r--r--supervisor/shared/rgb_led_colors.h2
-rw-r--r--supervisor/shared/rgb_led_status.c292
-rw-r--r--supervisor/shared/rgb_led_status.h10
-rw-r--r--supervisor/shared/safe_mode.c18
-rw-r--r--supervisor/shared/safe_mode.h30
-rw-r--r--supervisor/shared/serial.c68
-rw-r--r--[-rwxr-xr-x]supervisor/shared/stack.c10
-rw-r--r--[-rwxr-xr-x]supervisor/shared/stack.h2
-rw-r--r--supervisor/shared/tick.c12
-rw-r--r--supervisor/shared/translate.c28
-rw-r--r--supervisor/shared/translate.h8
-rw-r--r--supervisor/shared/usb/tusb_config.h20
-rw-r--r--supervisor/shared/usb/usb.c127
-rw-r--r--supervisor/shared/usb/usb_desc.c14
-rw-r--r--supervisor/shared/usb/usb_msc_flash.c68
-rw-r--r--supervisor/spi_flash_api.h12
-rw-r--r--supervisor/stub/filesystem.c6
-rw-r--r--supervisor/stub/safe_mode.c4
-rw-r--r--supervisor/stub/serial.c4
-rw-r--r--supervisor/stub/stack.c2
39 files changed, 1078 insertions, 1085 deletions
diff --git a/supervisor/linker.h b/supervisor/linker.h
index 74b2dd5a6..43050b907 100755..100644
--- a/supervisor/linker.h
+++ b/supervisor/linker.h
@@ -30,9 +30,9 @@
#define MICROPY_INCLUDED_SUPERVISOR_LINKER_H
#if defined(IMXRT10XX) || defined(FOMU) || defined(STM32H7)
-#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name )))
-#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name )))
-#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name ))) name
+#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name)))
+#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name)))
+#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name))) name
#else
#define PLACE_IN_DTCM_DATA(name) name
#define PLACE_IN_DTCM_BSS(name) name
diff --git a/supervisor/memory.h b/supervisor/memory.h
index 0f820eac1..0aa38eec3 100755..100644
--- a/supervisor/memory.h
+++ b/supervisor/memory.h
@@ -36,12 +36,12 @@
#include <stddef.h>
typedef struct {
- uint32_t* ptr;
+ uint32_t *ptr;
} supervisor_allocation;
-void free_memory(supervisor_allocation* allocation);
+void free_memory(supervisor_allocation *allocation);
// Find the allocation with the given ptr, NULL if not found. When called from the context of a
// supervisor_move_memory() callback, finds the allocation that had that ptr *before* the move, but
@@ -49,9 +49,9 @@ void free_memory(supervisor_allocation* allocation);
// When called with NULL, may return either NULL or an unused allocation whose ptr is NULL (this is
// a feature used internally in allocate_memory to save code size). Passing the return value to
// free_memory() is a permissible no-op in either case.
-supervisor_allocation* allocation_from_ptr(void *ptr);
+supervisor_allocation *allocation_from_ptr(void *ptr);
-supervisor_allocation* allocate_remaining_memory(void);
+supervisor_allocation *allocate_remaining_memory(void);
// Allocate a piece of a given length in bytes. If high_address is true then it should be allocated
// at a lower address from the top of the stack. Otherwise, addresses will increase starting after
@@ -62,13 +62,13 @@ supervisor_allocation* allocate_remaining_memory(void);
// The ptr of the returned supervisor_allocation will change at that point. If you need to be
// notified of that, add your own callback function at the designated place near the end of
// supervisor_move_memory().
-supervisor_allocation* allocate_memory(uint32_t length, bool high_address, bool movable);
+supervisor_allocation *allocate_memory(uint32_t length, bool high_address, bool movable);
static inline size_t align32_size(size_t size) {
return (size + 3) & ~3;
}
-size_t get_allocation_length(supervisor_allocation* allocation);
+size_t get_allocation_length(supervisor_allocation *allocation);
// Called after the GC heap is freed, transfers movable allocations from the GC heap to the
// supervisor heap and compacts the supervisor heap.
diff --git a/supervisor/port.h b/supervisor/port.h
index 812cf715b..0a8cdfd34 100644
--- a/supervisor/port.h
+++ b/supervisor/port.h
@@ -74,7 +74,7 @@ uint32_t port_get_saved_word(void);
// Get the raw tick count since start up. A tick is 1/1024 of a second, a common low frequency
// clock rate. If subticks is not NULL then the port will fill in the number of subticks where each
// tick is 32 subticks (for a resolution of 1/32768 or 30.5ish microseconds.)
-uint64_t port_get_raw_ticks(uint8_t* subticks);
+uint64_t port_get_raw_ticks(uint8_t *subticks);
// Enable 1/1024 second tick.
void port_enable_tick(void);
diff --git a/supervisor/serial.h b/supervisor/serial.h
index 066886303..e85231c6c 100644
--- a/supervisor/serial.h
+++ b/supervisor/serial.h
@@ -35,14 +35,14 @@
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
#include "lib/oofatfs/ff.h"
-extern FIL* boot_output_file;
+extern FIL *boot_output_file;
#endif
void serial_early_init(void);
void serial_init(void);
-void serial_write(const char* text);
+void serial_write(const char *text);
// Only writes up to given length. Does not check for null termination at all.
-void serial_write_substring(const char* text, uint32_t length);
+void serial_write_substring(const char *text, uint32_t length);
char serial_read(void);
bool serial_bytes_available(void);
bool serial_connected(void);
diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c
index 68a0a9667..0dafb5398 100644
--- a/supervisor/shared/background_callback.c
+++ b/supervisor/shared/background_callback.c
@@ -33,12 +33,13 @@
#include "supervisor/shared/tick.h"
#include "shared-bindings/microcontroller/__init__.h"
-STATIC volatile background_callback_t * volatile callback_head, * volatile callback_tail;
+STATIC volatile background_callback_t *volatile callback_head, *volatile callback_tail;
#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
-MP_WEAK void port_wake_main_task(void) {}
+MP_WEAK void port_wake_main_task(void) {
+}
void background_callback_add_core(background_callback_t *cb) {
CALLBACK_CRITICAL_BEGIN;
@@ -47,7 +48,7 @@ void background_callback_add_core(background_callback_t *cb) {
return;
}
cb->next = 0;
- cb->prev = (background_callback_t*)callback_tail;
+ cb->prev = (background_callback_t *)callback_tail;
if (callback_tail) {
callback_tail->next = cb;
}
@@ -77,7 +78,7 @@ void PLACE_IN_ITCM(background_callback_run_all)() {
return;
}
in_background_callback = true;
- background_callback_t *cb = (background_callback_t*)callback_head;
+ background_callback_t *cb = (background_callback_t *)callback_head;
callback_head = NULL;
callback_tail = NULL;
while (cb) {
@@ -107,8 +108,8 @@ void background_callback_end_critical_section() {
void background_callback_reset() {
CALLBACK_CRITICAL_BEGIN;
- background_callback_t *cb = (background_callback_t*)callback_head;
- while(cb) {
+ background_callback_t *cb = (background_callback_t *)callback_head;
+ while (cb) {
background_callback_t *next = cb->next;
memset(cb, 0, sizeof(*cb));
cb = next;
@@ -134,8 +135,8 @@ void background_callback_gc_collect(void) {
// It's necessary to traverse the whole list here, as the callbacks
// themselves can be in non-gc memory, and some of the cb->data
// objects themselves might be in non-gc memory.
- background_callback_t *cb = (background_callback_t*)callback_head;
- while(cb) {
+ background_callback_t *cb = (background_callback_t *)callback_head;
+ while (cb) {
gc_collect_ptr(cb->data);
cb = cb->next;
}
diff --git a/supervisor/shared/bluetooth.c b/supervisor/shared/bluetooth.c
index 56bf32117..00095c4f6 100644
--- a/supervisor/shared/bluetooth.c
+++ b/supervisor/shared/bluetooth.c
@@ -81,13 +81,13 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
}
// TODO: switch to Adafruit short UUID for the advertisement and add manufacturing data to distinguish ourselves from arduino.
_common_hal_bleio_adapter_start_advertising(&common_hal_bleio_adapter_obj,
- true,
- false, 0,
- 1.0,
- circuitpython_advertising_data,
- sizeof(circuitpython_advertising_data),
- circuitpython_scan_response_data,
- sizeof(circuitpython_scan_response_data));
+ true,
+ false, 0,
+ 1.0,
+ circuitpython_advertising_data,
+ sizeof(circuitpython_advertising_data),
+ circuitpython_scan_response_data,
+ sizeof(circuitpython_scan_response_data));
}
void supervisor_start_bluetooth(void) {
@@ -109,15 +109,15 @@ void supervisor_start_bluetooth(void) {
supervisor_ble_version_uuid.base.type = &bleio_uuid_type;
common_hal_bleio_uuid_construct(&supervisor_ble_version_uuid, 0x0203, circuitpython_base_uuid);
common_hal_bleio_characteristic_construct(&supervisor_ble_version_characteristic,
- &supervisor_ble_service,
- 0, // handle (for remote only)
- &supervisor_ble_version_uuid,
- CHAR_PROP_READ,
- SECURITY_MODE_OPEN,
- SECURITY_MODE_NO_ACCESS,
- 4, // max length
- true, // fixed length
- NULL); // no initial value
+ &supervisor_ble_service,
+ 0, // handle (for remote only)
+ &supervisor_ble_version_uuid,
+ CHAR_PROP_READ,
+ SECURITY_MODE_OPEN,
+ SECURITY_MODE_NO_ACCESS,
+ 4, // max length
+ true, // fixed length
+ NULL); // no initial value
uint32_t version = 1;
mp_buffer_info_t bufinfo;
@@ -129,15 +129,15 @@ void supervisor_start_bluetooth(void) {
supervisor_ble_filename_uuid.base.type = &bleio_uuid_type;
common_hal_bleio_uuid_construct(&supervisor_ble_filename_uuid, 0x0200, circuitpython_base_uuid);
common_hal_bleio_characteristic_construct(&supervisor_ble_filename_characteristic,
- &supervisor_ble_service,
- 0, // handle (for remote only)
- &supervisor_ble_filename_uuid,
- CHAR_PROP_READ | CHAR_PROP_WRITE,
- SECURITY_MODE_OPEN,
- SECURITY_MODE_OPEN,
- 500, // max length
- false, // fixed length
- NULL); // no initial value
+ &supervisor_ble_service,
+ 0, // handle (for remote only)
+ &supervisor_ble_filename_uuid,
+ CHAR_PROP_READ | CHAR_PROP_WRITE,
+ SECURITY_MODE_OPEN,
+ SECURITY_MODE_OPEN,
+ 500, // max length
+ false, // fixed length
+ NULL); // no initial value
char code_py[] = "/code.py";
bufinfo.buf = code_py;
@@ -148,29 +148,29 @@ void supervisor_start_bluetooth(void) {
supervisor_ble_length_uuid.base.type = &bleio_uuid_type;
common_hal_bleio_uuid_construct(&supervisor_ble_length_uuid, 0x0202, circuitpython_base_uuid);
common_hal_bleio_characteristic_construct(&supervisor_ble_length_characteristic,
- &supervisor_ble_service,
- 0, // handle (for remote only)
- &supervisor_ble_length_uuid,
- CHAR_PROP_NOTIFY | CHAR_PROP_READ,
- SECURITY_MODE_OPEN,
- SECURITY_MODE_NO_ACCESS,
- 4, // max length
- true, // fixed length
- NULL); // no initial value
+ &supervisor_ble_service,
+ 0, // handle (for remote only)
+ &supervisor_ble_length_uuid,
+ CHAR_PROP_NOTIFY | CHAR_PROP_READ,
+ SECURITY_MODE_OPEN,
+ SECURITY_MODE_NO_ACCESS,
+ 4, // max length
+ true, // fixed length
+ NULL); // no initial value
// File actions
supervisor_ble_contents_uuid.base.type = &bleio_uuid_type;
common_hal_bleio_uuid_construct(&supervisor_ble_contents_uuid, 0x0201, circuitpython_base_uuid);
common_hal_bleio_characteristic_construct(&supervisor_ble_contents_characteristic,
- &supervisor_ble_service,
- 0, // handle (for remote only)
- &supervisor_ble_contents_uuid,
- CHAR_PROP_NOTIFY | CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE,
- SECURITY_MODE_OPEN,
- SECURITY_MODE_OPEN,
- 500, // max length
- false, // fixed length
- NULL); // no initial value
+ &supervisor_ble_service,
+ 0, // handle (for remote only)
+ &supervisor_ble_contents_uuid,
+ CHAR_PROP_NOTIFY | CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE,
+ SECURITY_MODE_OPEN,
+ SECURITY_MODE_OPEN,
+ 500, // max length
+ false, // fixed length
+ NULL); // no initial value
supervisor_bluetooth_start_advertising();
vm_used_ble = false;
@@ -187,7 +187,7 @@ STATIC void update_file_length(void) {
bufinfo.buf = &file_length;
bufinfo.len = sizeof(file_length);
if (active_file.obj.fs != 0) {
- file_length = (int32_t) f_size(&active_file);
+ file_length = (int32_t)f_size(&active_file);
}
common_hal_bleio_characteristic_set_value(&supervisor_ble_length_characteristic, &bufinfo);
}
@@ -201,8 +201,8 @@ STATIC void open_current_file(void) {
size_t length = common_hal_bleio_characteristic_get_value(&supervisor_ble_filename_characteristic, path, max_len - 1);
path[length] = '\0';
- FATFS *fs = &((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs;
- f_open(fs, &active_file, (char*) path, FA_READ | FA_WRITE);
+ FATFS *fs = &((fs_user_mount_t *)MP_STATE_VM(vfs_mount_table)->obj)->fatfs;
+ f_open(fs, &active_file, (char *)path, FA_READ | FA_WRITE);
update_file_length();
}
@@ -238,12 +238,12 @@ void supervisor_bluetooth_background(void) {
new_filename = false;
// get length and set the characteristic for it
}
- uint16_t current_length = ((uint16_t*) current_command)[0];
+ uint16_t current_length = ((uint16_t *)current_command)[0];
if (current_length > 0 && current_length == current_offset) {
- uint16_t command = ((uint16_t *) current_command)[1];
+ uint16_t command = ((uint16_t *)current_command)[1];
if (command == 1) {
- uint16_t max_len = 20; //supervisor_ble_contents_characteristic.max_length;
+ uint16_t max_len = 20; // supervisor_ble_contents_characteristic.max_length;
uint8_t buf[max_len];
mp_buffer_info_t bufinfo;
bufinfo.buf = buf;
@@ -258,8 +258,8 @@ void supervisor_bluetooth_background(void) {
uint32_t offset = current_command[1];
uint32_t remove_length = current_command[2];
uint32_t insert_length = current_command[3];
- uint32_t file_length = (int32_t) f_size(&active_file);
- //uint32_t data_shift_length = fileLength - offset - remove_length;
+ uint32_t file_length = (int32_t)f_size(&active_file);
+ // uint32_t data_shift_length = fileLength - offset - remove_length;
int32_t data_shift = insert_length - remove_length;
uint32_t new_length = file_length + data_shift;
@@ -278,11 +278,11 @@ void supervisor_bluetooth_background(void) {
f_lseek(&active_file, file_length);
// Fill end with 0xff so we don't need to erase.
uint8_t data = 0xff;
- for (size_t i = 0; i < (size_t) data_shift; i++) {
+ for (size_t i = 0; i < (size_t)data_shift; i++) {
UINT actual;
f_write(&active_file, &data, 1, &actual);
}
- for (uint32_t shift_offset = new_length - 1; shift_offset >= offset + insert_length ; shift_offset--) {
+ for (uint32_t shift_offset = new_length - 1; shift_offset >= offset + insert_length; shift_offset--) {
UINT actual;
f_lseek(&active_file, shift_offset - data_shift);
f_read(&active_file, &data, 1, &actual);
@@ -292,7 +292,7 @@ void supervisor_bluetooth_background(void) {
}
f_lseek(&active_file, offset);
- uint8_t* data = (uint8_t *) (current_command + 4);
+ uint8_t *data = (uint8_t *)(current_command + 4);
UINT written;
f_write(&active_file, data, insert_length, &written);
f_sync(&active_file);
diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c
index 6d648510e..427c17924 100644
--- a/supervisor/shared/board.c
+++ b/supervisor/shared/board.c
@@ -33,7 +33,7 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/neopixel_write/__init__.h"
-void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count) {
+void board_reset_user_neopixels(const mcu_pin_obj_t *pin, size_t count) {
// Turn off on-board NeoPixel string
uint8_t empty[count * 3];
memset(empty, 0, count * 3);
diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h
index fe887a933..def5f4865 100644
--- a/supervisor/shared/board.h
+++ b/supervisor/shared/board.h
@@ -31,6 +31,6 @@
#include "shared-bindings/microcontroller/Pin.h"
-void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count);
+void board_reset_user_neopixels(const mcu_pin_obj_t *pin, size_t count);
#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H
diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c
index 1919cf4a4..6ee6c7386 100644
--- a/supervisor/shared/display.c
+++ b/supervisor/shared/display.c
@@ -50,7 +50,7 @@ extern displayio_bitmap_t blinka_bitmap;
extern displayio_group_t circuitpython_splash;
#if CIRCUITPY_TERMINALIO
-static supervisor_allocation* tilegrid_tiles = NULL;
+static supervisor_allocation *tilegrid_tiles = NULL;
#endif
void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
@@ -59,10 +59,10 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
uint8_t scale = 2;
#if CIRCUITPY_TERMINALIO
- displayio_tilegrid_t* grid = &supervisor_terminal_text_grid;
+ displayio_tilegrid_t *grid = &supervisor_terminal_text_grid;
bool tall = height_px > width_px;
uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width;
- uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px ;
+ uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px;
uint16_t width_in_tiles = terminal_width_px / grid->tile_width;
// determine scale based on h
if (width_in_tiles < 80) {
@@ -94,7 +94,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
return;
}
}
- uint8_t* tiles = (uint8_t*) tilegrid_tiles->ptr;
+ uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr;
grid->y = tall ? blinka_bitmap.height : 0;
grid->x = tall ? 0 : blinka_bitmap.width;
@@ -130,7 +130,7 @@ void supervisor_stop_terminal(void) {
void supervisor_display_move_memory(void) {
#if CIRCUITPY_TERMINALIO
if (tilegrid_tiles != NULL) {
- supervisor_terminal_text_grid.tiles = (uint8_t*) tilegrid_tiles->ptr;
+ supervisor_terminal_text_grid.tiles = (uint8_t *)tilegrid_tiles->ptr;
} else {
supervisor_terminal_text_grid.tiles = NULL;
}
@@ -139,16 +139,16 @@ void supervisor_display_move_memory(void) {
#if CIRCUITPY_DISPLAYIO
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
#if CIRCUITPY_RGBMATRIX
- if (displays[i].rgbmatrix.base.type == &rgbmatrix_RGBMatrix_type) {
- rgbmatrix_rgbmatrix_obj_t * pm = &displays[i].rgbmatrix;
- common_hal_rgbmatrix_rgbmatrix_reconstruct(pm, NULL);
- }
+ if (displays[i].rgbmatrix.base.type == &rgbmatrix_RGBMatrix_type) {
+ rgbmatrix_rgbmatrix_obj_t *pm = &displays[i].rgbmatrix;
+ common_hal_rgbmatrix_rgbmatrix_reconstruct(pm, NULL);
+ }
#endif
#if CIRCUITPY_SHARPDISPLAY
- if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type) {
- sharpdisplay_framebuffer_obj_t * sharp = &displays[i].sharpdisplay;
- common_hal_sharpdisplay_framebuffer_reconstruct(sharp);
- }
+ if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type) {
+ sharpdisplay_framebuffer_obj_t *sharp = &displays[i].sharpdisplay;
+ common_hal_sharpdisplay_framebuffer_reconstruct(sharp);
+ }
#endif
}
#endif
diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h
index c8c941adf..edc6419ef 100644
--- a/supervisor/shared/external_flash/devices.h
+++ b/supervisor/shared/external_flash/devices.h
@@ -55,662 +55,662 @@ typedef struct {
// Supports the quad input page program command 0x32. This is known as 1-1-4 because it only
// uses all four lines for data.
- bool supports_qspi_writes: 1;
+ bool supports_qspi_writes : 1;
// Requires a separate command 0x31 to write to the second byte of the status register.
// Otherwise two byte are written via 0x01.
- bool write_status_register_split: 1;
+ bool write_status_register_split : 1;
// True when the status register is a single byte. This implies the Quad Enable bit is in the
// first byte and the Read Status Register 2 command (0x35) is unsupported.
- bool single_status_byte: 1;
+ bool single_status_byte : 1;
// Does not support using a ready bit within the status register
- bool no_ready_bit: 1;
+ bool no_ready_bit : 1;
// Does not support the erase command (0x20)
- bool no_erase_cmd: 1;
+ bool no_erase_cmd : 1;
// Device does not have a reset command
- bool no_reset_cmd: 1;
+ bool no_reset_cmd : 1;
} external_flash_device;
// Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. It's on the SAMD21
// Xplained board.
// Datasheet: https://www.adestotech.com/wp-content/uploads/doc8715.pdf
-#define AT25DF081A {\
- .total_size = (1 << 20), /* 1 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x1f, \
- .memory_type = 0x45, \
- .capacity = 0x01, \
- .max_clock_speed_mhz = 85, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = true, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define AT25DF081A { \
+ .total_size = (1 << 20), /* 1 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x1f, \
+ .memory_type = 0x45, \
+ .capacity = 0x01, \
+ .max_clock_speed_mhz = 85, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = true, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Adesto Tech AT25DF641-SSHD-T 8MiB SPI flash
// for the Oak Dev Tech Icy Tree M0 (SAMD21) feather board.
// Source: https://www.digikey.com/product-detail/en/adesto-technologies/AT25SF641-SDHD-T/1265-1180-1-ND/
// Datasheet: https://www.adestotech.com/wp-content/uploads/doc8693.pdf
-#define AT25DF641A {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x1f, \
- .memory_type = 0x48, \
- .capacity = 0x00, \
- .max_clock_speed_mhz = 85, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = true, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define AT25DF641A { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x1f, \
+ .memory_type = 0x48, \
+ .capacity = 0x00, \
+ .max_clock_speed_mhz = 85, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = true, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Adesto Tech AT25SF161-SSHD-T 2MiB SPI flash
// for the StringCar M0 (SAMD21) Express board.
// Source: https://www.digikey.com/product-detail/en/adesto-technologies/AT25SF161-SDHD-T/1265-1230-1-ND/
// Datasheet: https://www.adestotech.com/wpo-content/uploads/jDS-AT25SF161_046.pdf
-#define AT25SF161 {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x1f, \
- .memory_type = 0x86, \
- .capacity = 0x01, \
- .max_clock_speed_mhz = 85, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = true, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define AT25SF161 { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x1f, \
+ .memory_type = 0x86, \
+ .capacity = 0x01, \
+ .max_clock_speed_mhz = 85, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = true, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Adesto Tech AT25SF041 1MiB SPI flash. It's on the SparkFun
// SAMD51 Thing Plus board
// Datasheet: https://www.adestotech.com/wp-content/uploads/DS-AT25SF041_044.pdf
-#define AT25SF041A {\
- .total_size = (1 << 19), /* 512 KiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x1f, \
- .memory_type = 0x84, \
- .capacity = 0x01, \
- .max_clock_speed_mhz = 85, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define AT25SF041A { \
+ .total_size = (1 << 19), /* 512 KiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x1f, \
+ .memory_type = 0x84, \
+ .capacity = 0x01, \
+ .max_clock_speed_mhz = 85, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Gigadevice GD25Q16C 2MiB SPI flash.
// Datasheet: http://www.gigadevice.com/datasheet/gd25q16c/
-#define GD25Q16C {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc8, \
- .memory_type = 0x40, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define GD25Q16C { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc8, \
+ .memory_type = 0x40, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Gigadevice GD25Q32C 4MiB SPI flash.
// Datasheet: http://www.elm-tech.com/en/products/spi-flash-memory/gd25q32/gd25q32.pdf
-#define GD25Q32C {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc8, \
- .memory_type = 0x40, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = true, \
- .single_status_byte = false, \
+#define GD25Q32C { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc8, \
+ .memory_type = 0x40, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = true, \
+ .single_status_byte = false, \
}
// Settings for the Gigadevice GD25Q64C 8MiB SPI flash.
// Datasheet: http://www.elm-tech.com/en/products/spi-flash-memory/gd25q64/gd25q64.pdf
-#define GD25Q64C {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc8, \
- .memory_type = 0x40, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = true, \
- .single_status_byte = false, \
+#define GD25Q64C { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc8, \
+ .memory_type = 0x40, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = true, \
+ .single_status_byte = false, \
}
// Settings for the Gigadevice GD25S512MD 64MiB SPI flash.
// Datasheet: http://www.gigadevice.com/datasheet/gd25s512md/
-#define GD25S512MD {\
- .total_size = (1 << 26), /* 64 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc8, \
- .memory_type = 0x40, \
- .capacity = 0x19, \
- .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = true, \
- .single_status_byte = false, \
+#define GD25S512MD { \
+ .total_size = (1 << 26), /* 64 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc8, \
+ .memory_type = 0x40, \
+ .capacity = 0x19, \
+ .max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = true, \
+ .single_status_byte = false, \
}
// Settings for the Cypress (was Spansion) S25FL064L 8MiB SPI flash.
// Datasheet: http://www.cypress.com/file/316661/download
-#define S25FL064L {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 300, \
- .manufacturer_id = 0x01, \
- .memory_type = 0x60, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 108, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define S25FL064L { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 300, \
+ .manufacturer_id = 0x01, \
+ .memory_type = 0x60, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 108, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Cypress (was Spansion) S25FL116K 2MiB SPI flash.
// Datasheet: http://www.cypress.com/file/196886/download
-#define S25FL116K {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x01, \
- .memory_type = 0x40, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 108, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define S25FL116K { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x01, \
+ .memory_type = 0x40, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 108, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Cypress (was Spansion) S25FL216K 2MiB SPI flash.
// Datasheet: http://www.cypress.com/file/197346/download
-#define S25FL216K {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x01, \
- .memory_type = 0x40, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 65, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define S25FL216K { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x01, \
+ .memory_type = 0x40, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 65, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q16FW 2MiB SPI flash.
// Datasheet: https://www.winbond.com/resource-files/w25q16fw%20revj%2005182017%20sfdp.pdf
-#define W25Q16FW {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x60, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q16FW { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x60, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q16JV-IQ 2MiB SPI flash. Note that JV-IM has a different .memory_type (0x70)
// Datasheet: https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf
-#define W25Q16JV_IQ {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q16JV_IQ { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q16JV-IM 2MiB SPI flash. Note that JV-IQ has a different .memory_type (0x40)
// Datasheet: https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf
-#define W25Q16JV_IM {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x70, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
+#define W25Q16JV_IM { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x70, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
}
// Settings for the Winbond W25Q32BV 4MiB SPI flash.
// Datasheet: https://www.winbond.com/resource-files/w25q32bv_revi_100413_wo_automotive.pdf
-#define W25Q32BV {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x60, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 104, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q32BV { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x60, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 104, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q32JV-IM 4MiB SPI flash.
// Datasheet: https://www.winbond.com/resource-files/w25q32jv%20revg%2003272018%20plus.pdf
-#define W25Q32JV_IM {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x70, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
+#define W25Q32JV_IM { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x70, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
}
// Settings for the Winbond W25Q32JV-IQ 4MiB SPI flash.
// Datasheet: https://www.mouser.com/datasheet/2/949/w25q32jv_revg_03272018_plus-1489806.pdf
-#define W25Q32JV_IQ {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
+#define W25Q32JV_IQ { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
}
// Settings for the Winbond W25Q64FV 8MiB SPI flash.
// Datasheet: https://www.winbond.com/resource-files/w25q64fv%20revs%2007182017.pdf
-#define W25Q64FV {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 104, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q64FV { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 104, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q64JV-IM 8MiB SPI flash. Note that JV-IQ has a different .memory_type (0x40)
// Datasheet: http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
-#define W25Q64JV_IM {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x70, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q64JV_IM { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x70, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q64JV-IQ 8MiB SPI flash. Note that JV-IM has a different .memory_type (0x70)
// Datasheet: http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
-#define W25Q64JV_IQ {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q64JV_IQ { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q80DL 1MiB SPI flash.
// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf
-#define W25Q80DL {\
- .total_size = (1 << 20), /* 1 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x60, \
- .capacity = 0x14, \
- .max_clock_speed_mhz = 104, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q80DL { \
+ .total_size = (1 << 20), /* 1 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x60, \
+ .capacity = 0x14, \
+ .max_clock_speed_mhz = 104, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q80DV 1MiB SPI flash.. Note that W25Q80DL has a different memory type (0x60)
// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf
-#define W25Q80DV {\
- .total_size = (1 << 20), /* 1 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x14, \
- .max_clock_speed_mhz = 104, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q80DV { \
+ .total_size = (1 << 20), /* 1 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x14, \
+ .max_clock_speed_mhz = 104, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Winbond W25Q128JV-SQ 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70)
// Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
-#define W25Q128JV_SQ {\
- .total_size = (1 << 24), /* 16 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x18, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q128JV_SQ { \
+ .total_size = (1 << 24), /* 16 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x18, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the Everspin MR20H40 / MR25H40 magnetic non-volatile RAM
// Datasheet: https://www.everspin.com/supportdocs/MR25H40CDFR
-#define MR2xH40 {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0xef, /*no JDEC*/ \
- .memory_type = 0x40, /*no JDEC*/ \
- .capacity = 0x14, /*no JDEC*/ \
- .max_clock_speed_mhz = 10, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = false, \
- .supports_fast_read = false, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
- .no_ready_bit = true, \
- .no_erase_cmd = true, \
- .no_reset_cmd = true, \
+#define MR2xH40 { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0xef, /*no JDEC*/ \
+ .memory_type = 0x40, /*no JDEC*/ \
+ .capacity = 0x14, /*no JDEC*/ \
+ .max_clock_speed_mhz = 10, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = false, \
+ .supports_fast_read = false, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
+ .no_ready_bit = true, \
+ .no_erase_cmd = true, \
+ .no_reset_cmd = true, \
}
// Settings for the Macronix MX25L1606 2MiB SPI flash.
// Datasheet:
-#define MX25L1606 {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x20, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 8, \
- .quad_enable_bit_mask = 0x40, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25L1606 { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x20, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 8, \
+ .quad_enable_bit_mask = 0x40, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25L3233F 4MiB SPI flash.
// Datasheet: http://www.macronix.com/Lists/Datasheet/Attachments/7426/MX25L3233F,%203V,%2032Mb,%20v1.6.pdf
-#define MX25L3233F {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x20, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x40, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25L3233F { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x20, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x40, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25R6435F 8MiB SPI flash.
// Datasheet: http://www.macronix.com/Lists/Datasheet/Attachments/7428/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.4.pdf
// By default its in lower power mode which can only do 8mhz. In high power mode it can do 80mhz.
-#define MX25R6435F {\
- .total_size = (1 << 23), /* 8 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x28, \
- .capacity = 0x17, \
- .max_clock_speed_mhz = 8, \
- .quad_enable_bit_mask = 0x40, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25R6435F { \
+ .total_size = (1 << 23), /* 8 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x28, \
+ .capacity = 0x17, \
+ .max_clock_speed_mhz = 8, \
+ .quad_enable_bit_mask = 0x40, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25R1635F 8MiB SPI flash.
// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7595/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf
// In low power mode, quad operations can only run at 8 MHz.
-#define MX25R1635F {\
- .total_size = (1 << 21), /* 2 MiB */ \
- .start_up_time_us = 800, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x28, \
- .capacity = 0x15, \
- .max_clock_speed_mhz = 33, /* 8 mhz for dual/quad */ \
- .quad_enable_bit_mask = 0x80, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25R1635F { \
+ .total_size = (1 << 21), /* 2 MiB */ \
+ .start_up_time_us = 800, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x28, \
+ .capacity = 0x15, \
+ .max_clock_speed_mhz = 33, /* 8 mhz for dual/quad */ \
+ .quad_enable_bit_mask = 0x80, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25L51245G 64MiB SPI flash.
// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7437/MX25L51245G,%203V,%20512Mb,%20v1.6.pdf
-#define MX25L51245G {\
- .total_size = (1 << 26), /* 64 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x20, \
- .capacity = 0x1a, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x40, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25L51245G { \
+ .total_size = (1 << 26), /* 64 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x20, \
+ .capacity = 0x1a, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x40, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25L51245G 64MiB SPI flash.
// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7437/MX25L51245G,%203V,%20512Mb,%20v1.6.pdf
-#define MX25L25645G {\
- .total_size = (1 << 25), /* 32 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0x9f, \
- .memory_type = 0xab, \
- .capacity = 0x90, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0xaf, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define MX25L25645G { \
+ .total_size = (1 << 25), /* 32 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0x9f, \
+ .memory_type = 0xab, \
+ .capacity = 0x90, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0xaf, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Macronix MX25L12833F 16MiB SPI flash
// Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7447/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf
-#define MX25L12833F {\
- .total_size = (1UL << 24), /* 16 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xc2, \
- .memory_type = 0x20, \
- .capacity = 0x18, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x40, \
- .has_sector_protection = true, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
- }
+#define MX25L12833F { \
+ .total_size = (1UL << 24), /* 16 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xc2, \
+ .memory_type = 0x20, \
+ .capacity = 0x18, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x40, \
+ .has_sector_protection = true, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
+}
// Settings for the Winbond W25Q128JV-PM 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70)
// Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
-#define W25Q128JV_PM {\
- .total_size = (1 << 24), /* 16 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x70, \
- .capacity = 0x18, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
+#define W25Q128JV_PM { \
+ .total_size = (1 << 24), /* 16 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x70, \
+ .capacity = 0x18, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
}
// Settings for the Winbond W25Q32FV 4MiB SPI flash.
// Datasheet:http://www.winbond.com/resource-files/w25q32fv%20revj%2006032016.pdf?__locale=en
-#define W25Q32FV {\
- .total_size = (1 << 22), /* 4 MiB */ \
- .start_up_time_us = 5000, \
- .manufacturer_id = 0xef, \
- .memory_type = 0x40, \
- .capacity = 0x16, \
- .max_clock_speed_mhz = 104, \
- .quad_enable_bit_mask = 0x00, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = false, \
- .supports_qspi_writes = false, \
- .write_status_register_split = false, \
- .single_status_byte = false, \
+#define W25Q32FV { \
+ .total_size = (1 << 22), /* 4 MiB */ \
+ .start_up_time_us = 5000, \
+ .manufacturer_id = 0xef, \
+ .memory_type = 0x40, \
+ .capacity = 0x16, \
+ .max_clock_speed_mhz = 104, \
+ .quad_enable_bit_mask = 0x00, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = false, \
+ .supports_qspi_writes = false, \
+ .write_status_register_split = false, \
+ .single_status_byte = false, \
}
// Settings for the ISSI IS25LP128F 16MiB SPI flash.
// Datasheet: http://www.issi.com/WW/pdf/25LP-WP128F.pdf
-#define IS25LP128F {\
- .total_size = (1 << 24), /* 16 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x9d, \
- .memory_type = 0x60, \
- .capacity = 0x18, \
- .max_clock_speed_mhz = 133, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = true, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define IS25LP128F { \
+ .total_size = (1 << 24), /* 16 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x9d, \
+ .memory_type = 0x60, \
+ .capacity = 0x18, \
+ .max_clock_speed_mhz = 133, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = true, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
// Settings for the Micron N25Q256A 256Mb (32MiB) QSPI flash.
// Datasheet: https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_256mb_3v.pdf
-#define N25Q256A {\
- /* .total_size = (1 << 25), 32 MiB does not work at this time, as assumptions about 3-byte addresses abound */ \
- .total_size = (1 << 24), /* 16 MiB */ \
- .start_up_time_us = 10000, \
- .manufacturer_id = 0x20, \
- .memory_type = 0xBA, \
- .capacity = 0x19, \
- .max_clock_speed_mhz = 108, \
- .quad_enable_bit_mask = 0x02, \
- .has_sector_protection = false, \
- .supports_fast_read = true, \
- .supports_qspi = true, \
- .supports_qspi_writes = true, \
- .write_status_register_split = false, \
- .single_status_byte = true, \
+#define N25Q256A { \
+ /* .total_size = (1 << 25), 32 MiB does not work at this time, as assumptions about 3-byte addresses abound */ \
+ .total_size = (1 << 24), /* 16 MiB */ \
+ .start_up_time_us = 10000, \
+ .manufacturer_id = 0x20, \
+ .memory_type = 0xBA, \
+ .capacity = 0x19, \
+ .max_clock_speed_mhz = 108, \
+ .quad_enable_bit_mask = 0x02, \
+ .has_sector_protection = false, \
+ .supports_fast_read = true, \
+ .supports_qspi = true, \
+ .supports_qspi_writes = true, \
+ .write_status_register_split = false, \
+ .single_status_byte = true, \
}
#endif // MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H
diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c
index 23727e7e7..f8054a9fe 100644
--- a/supervisor/shared/external_flash/external_flash.c
+++ b/supervisor/shared/external_flash/external_flash.c
@@ -48,19 +48,19 @@ static uint32_t current_sector;
STATIC const external_flash_device possible_devices[] = {EXTERNAL_FLASH_DEVICES};
#define EXTERNAL_FLASH_DEVICE_COUNT MP_ARRAY_SIZE(possible_devices)
-static const external_flash_device* flash_device = NULL;
+static const external_flash_device *flash_device = NULL;
// Track which blocks (up to 32) in the current sector currently live in the
// cache.
static uint32_t dirty_mask;
-static supervisor_allocation* supervisor_cache = NULL;
+static supervisor_allocation *supervisor_cache = NULL;
// Wait until both the write enable and write in progress bits have cleared.
static bool wait_for_flash_ready(void) {
bool ok = true;
// Both the write enable and write in progress bits should be low.
- if (flash_device->no_ready_bit){
+ if (flash_device->no_ready_bit) {
// For NVM without a ready bit in status register
return ok;
}
@@ -77,7 +77,7 @@ static bool write_enable(void) {
}
// Read data_length's worth of bytes starting at address into data.
-static bool read_flash(uint32_t address, uint8_t* data, uint32_t data_length) {
+static bool read_flash(uint32_t address, uint8_t *data, uint32_t data_length) {
if (flash_device == NULL) {
return false;
}
@@ -90,13 +90,13 @@ static bool read_flash(uint32_t address, uint8_t* data, uint32_t data_length) {
// Writes data_length's worth of bytes starting at address from data. Assumes
// that the sector that address resides in has already been erased. So make sure
// to run erase_sector.
-static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_length) {
+static bool write_flash(uint32_t address, const uint8_t *data, uint32_t data_length) {
if (flash_device == NULL) {
return false;
}
// Don't bother writing if the data is all 1s. Thats equivalent to the flash
// state after an erase.
- if (!flash_device->no_erase_cmd){
+ if (!flash_device->no_erase_cmd) {
// Only do this if the device has an erase command
bool all_ones = true;
for (uint16_t i = 0; i < data_length; i++) {
@@ -111,14 +111,14 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len
}
for (uint32_t bytes_written = 0;
- bytes_written < data_length;
- bytes_written += SPI_FLASH_PAGE_SIZE) {
+ bytes_written < data_length;
+ bytes_written += SPI_FLASH_PAGE_SIZE) {
if (!wait_for_flash_ready() || !write_enable()) {
return false;
}
- if (!spi_flash_write_data(address + bytes_written, (uint8_t*) data + bytes_written,
- SPI_FLASH_PAGE_SIZE)) {
+ if (!spi_flash_write_data(address + bytes_written, (uint8_t *)data + bytes_written,
+ SPI_FLASH_PAGE_SIZE)) {
return false;
}
}
@@ -128,7 +128,7 @@ static bool write_flash(uint32_t address, const uint8_t* data, uint32_t data_len
static bool page_erased(uint32_t sector_address) {
// Check the first few bytes to catch the common case where there is data
// without using a bunch of memory.
- if (flash_device->no_erase_cmd){
+ if (flash_device->no_erase_cmd) {
// skip this if device doesn't have an erase command.
return true;
}
@@ -162,7 +162,7 @@ static bool page_erased(uint32_t sector_address) {
static bool erase_sector(uint32_t sector_address) {
// Before we erase the sector we need to wait for any writes to finish and
// and then enable the write again.
- if (flash_device->no_erase_cmd){
+ if (flash_device->no_erase_cmd) {
// skip this if device doesn't have an erase command.
return true;
}
@@ -209,33 +209,33 @@ void supervisor_flash_init(void) {
spi_flash_init();
-#ifdef EXTERNAL_FLASH_NO_JEDEC
+ #ifdef EXTERNAL_FLASH_NO_JEDEC
// For NVM that don't have JEDEC response
spi_flash_command(CMD_WAKE);
for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
- const external_flash_device* possible_device = &possible_devices[i];
+ const external_flash_device *possible_device = &possible_devices[i];
flash_device = possible_device;
break;
}
-#else
+ #else
// The response will be 0xff if the flash needs more time to start up.
uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff};
while (jedec_id_response[0] == 0xff) {
spi_flash_read_command(CMD_READ_JEDEC_ID, jedec_id_response, 3);
}
- for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
- const external_flash_device* possible_device = &possible_devices[i];
- if (jedec_id_response[0] == possible_device->manufacturer_id &&
- jedec_id_response[1] == possible_device->memory_type &&
- jedec_id_response[2] == possible_device->capacity) {
- flash_device = possible_device;
- break;
- }
- }
-#endif
- if (flash_device == NULL) {
- return;
+ for (uint8_t i = 0; i < EXTERNAL_FLASH_DEVICE_COUNT; i++) {
+ const external_flash_device *possible_device = &possible_devices[i];
+ if (jedec_id_response[0] == possible_device->manufacturer_id &&
+ jedec_id_response[1] == possible_device->memory_type &&
+ jedec_id_response[2] == possible_device->capacity) {
+ flash_device = possible_device;
+ break;
}
+ }
+ #endif
+ if (flash_device == NULL) {
+ return;
+ }
// We don't know what state the flash is in so wait for any remaining writes and then reset.
uint8_t read_status_response[1] = {0x00};
@@ -250,7 +250,7 @@ void supervisor_flash_init(void) {
} while ((read_status_response[0] & 0x80) != 0);
}
- if (!(flash_device->no_reset_cmd)){
+ if (!(flash_device->no_reset_cmd)) {
spi_flash_command(CMD_ENABLE_RESET);
spi_flash_command(CMD_RESET);
}
@@ -261,14 +261,14 @@ void supervisor_flash_init(void) {
spi_flash_init_device(flash_device);
// Activity LED for flash writes.
-#ifdef MICROPY_HW_LED_MSC
+ #ifdef MICROPY_HW_LED_MSC
gpio_set_pin_function(SPI_FLASH_CS_PIN, GPIO_PIN_FUNCTION_OFF);
gpio_set_pin_direction(MICROPY_HW_LED_MSC, GPIO_DIRECTION_OUT);
// There's already a pull-up on the board.
gpio_set_pin_level(MICROPY_HW_LED_MSC, false);
-#endif
+ #endif
- if (flash_device->has_sector_protection) {
+ if (flash_device->has_sector_protection) {
write_enable();
// Turn off sector protection
@@ -312,7 +312,7 @@ static bool flush_scratch_flash(void) {
if ((dirty_mask & (1 << i)) == 0) {
copy_to_scratch_ok = copy_to_scratch_ok &&
copy_block(current_sector + i * FILESYSTEM_BLOCK_SIZE,
- scratch_sector + i * FILESYSTEM_BLOCK_SIZE);
+ scratch_sector + i * FILESYSTEM_BLOCK_SIZE);
}
}
if (!copy_to_scratch_ok) {
@@ -325,7 +325,7 @@ static bool flush_scratch_flash(void) {
// Finally, copy the new version into it.
for (uint8_t i = 0; i < SPI_FLASH_ERASE_SIZE / FILESYSTEM_BLOCK_SIZE; i++) {
copy_block(scratch_sector + i * FILESYSTEM_BLOCK_SIZE,
- current_sector + i * FILESYSTEM_BLOCK_SIZE);
+ current_sector + i * FILESYSTEM_BLOCK_SIZE);
}
return true;
}
@@ -341,8 +341,8 @@ static bool allocate_ram_cache(void) {
// Attempt to allocate outside the heap first.
supervisor_cache = allocate_memory(table_size + SPI_FLASH_ERASE_SIZE, false, false);
if (supervisor_cache != NULL) {
- MP_STATE_VM(flash_ram_cache) = (uint8_t **) supervisor_cache->ptr;
- uint8_t* page_start = (uint8_t *) supervisor_cache->ptr + table_size;
+ MP_STATE_VM(flash_ram_cache) = (uint8_t **)supervisor_cache->ptr;
+ uint8_t *page_start = (uint8_t *)supervisor_cache->ptr + table_size;
for (uint8_t i = 0; i < blocks_per_sector; i++) {
for (uint8_t j = 0; j < pages_per_block; j++) {
@@ -446,8 +446,8 @@ static bool flush_ram_cache(bool keep_cache) {
for (uint8_t i = 0; i < SPI_FLASH_ERASE_SIZE / FILESYSTEM_BLOCK_SIZE; i++) {
for (uint8_t j = 0; j < pages_per_block; j++) {
write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE,
- MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j],
- SPI_FLASH_PAGE_SIZE);
+ MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j],
+ SPI_FLASH_PAGE_SIZE);
if (!keep_cache && supervisor_cache == NULL && MP_STATE_MEM(gc_pool_start)) {
m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]);
}
@@ -464,7 +464,7 @@ static bool flush_ram_cache(bool keep_cache) {
// TODO Don't blink the status indicator if we don't actually do any writing (hard to tell right now).
static void spi_flash_flush_keep_cache(bool keep_cache) {
#ifdef MICROPY_HW_LED_MSC
- port_pin_set_output_level(MICROPY_HW_LED_MSC, true);
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, true);
#endif
temp_status_color(ACTIVE_WRITE);
// If we've cached to the flash itself flush from there.
@@ -476,7 +476,7 @@ static void spi_flash_flush_keep_cache(bool keep_cache) {
current_sector = NO_SECTOR_LOADED;
clear_temp_status();
#ifdef MICROPY_HW_LED_MSC
- port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
#endif
}
@@ -514,8 +514,8 @@ bool external_flash_read_block(uint8_t *dest, uint32_t block) {
uint8_t pages_per_block = FILESYSTEM_BLOCK_SIZE / SPI_FLASH_PAGE_SIZE;
for (int i = 0; i < pages_per_block; i++) {
memcpy(dest + i * SPI_FLASH_PAGE_SIZE,
- MP_STATE_VM(flash_ram_cache)[block_index * pages_per_block + i],
- SPI_FLASH_PAGE_SIZE);
+ MP_STATE_VM(flash_ram_cache)[block_index * pages_per_block + i],
+ SPI_FLASH_PAGE_SIZE);
}
return true;
} else {
@@ -563,8 +563,8 @@ bool external_flash_write_block(const uint8_t *data, uint32_t block) {
uint8_t pages_per_block = FILESYSTEM_BLOCK_SIZE / SPI_FLASH_PAGE_SIZE;
for (int i = 0; i < pages_per_block; i++) {
memcpy(MP_STATE_VM(flash_ram_cache)[block_index * pages_per_block + i],
- data + i * SPI_FLASH_PAGE_SIZE,
- SPI_FLASH_PAGE_SIZE);
+ data + i * SPI_FLASH_PAGE_SIZE,
+ SPI_FLASH_PAGE_SIZE);
}
return true;
} else {
diff --git a/supervisor/shared/external_flash/external_flash_root_pointers.h b/supervisor/shared/external_flash/external_flash_root_pointers.h
index cb1b86d19..0613c9a57 100644
--- a/supervisor/shared/external_flash/external_flash_root_pointers.h
+++ b/supervisor/shared/external_flash/external_flash_root_pointers.h
@@ -30,6 +30,6 @@
// We use this when we can allocate the whole cache in RAM.
#define FLASH_ROOT_POINTERS \
- uint8_t** flash_ram_cache; \
+ uint8_t **flash_ram_cache; \
#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_EXTERNAL_FLASH_ROOT_POINTERS_H
diff --git a/supervisor/shared/external_flash/qspi_flash.c b/supervisor/shared/external_flash/qspi_flash.c
index 48266540c..dc16f3465 100644
--- a/supervisor/shared/external_flash/qspi_flash.c
+++ b/supervisor/shared/external_flash/qspi_flash.c
@@ -28,7 +28,7 @@
#include "supervisor/shared/external_flash/common_commands.h"
-void check_quad_enable(const external_flash_device* device) {
+void check_quad_enable(const external_flash_device *device) {
if (device->quad_enable_bit_mask == 0x00) {
return;
}
diff --git a/supervisor/shared/external_flash/qspi_flash.h b/supervisor/shared/external_flash/qspi_flash.h
index b72e37b26..c0c089ee0 100644
--- a/supervisor/shared/external_flash/qspi_flash.h
+++ b/supervisor/shared/external_flash/qspi_flash.h
@@ -26,6 +26,6 @@
#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_QSPI_FLASH_H
#define MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_QSPI_FLASH_H
-void check_quad_enable(const external_flash_device* device);
+void check_quad_enable(const external_flash_device *device);
#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_QSPI_FLASH_H
diff --git a/supervisor/shared/external_flash/spi_flash.c b/supervisor/shared/external_flash/spi_flash.c
index 67e64c970..3ddd92b5e 100644
--- a/supervisor/shared/external_flash/spi_flash.c
+++ b/supervisor/shared/external_flash/spi_flash.c
@@ -38,12 +38,13 @@
digitalio_digitalinout_obj_t cs_pin;
busio_spi_obj_t supervisor_flash_spi_bus;
-const external_flash_device* flash_device;
+const external_flash_device *flash_device;
uint32_t spi_flash_baudrate;
// Enable the flash over SPI.
static void flash_enable(void) {
- while (!common_hal_busio_spi_try_lock(&supervisor_flash_spi_bus)) {}
+ while (!common_hal_busio_spi_try_lock(&supervisor_flash_spi_bus)) {
+ }
common_hal_digitalio_digitalinout_set_value(&cs_pin, false);
}
@@ -53,7 +54,7 @@ static void flash_disable(void) {
common_hal_busio_spi_unlock(&supervisor_flash_spi_bus);
}
-static bool transfer(uint8_t* command, uint32_t command_length, uint8_t* data_in, uint8_t* data_out, uint32_t data_length) {
+static bool transfer(uint8_t *command, uint32_t command_length, uint8_t *data_in, uint8_t *data_out, uint32_t data_length) {
flash_enable();
bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, command, command_length);
if (status) {
@@ -69,7 +70,7 @@ static bool transfer(uint8_t* command, uint32_t command_length, uint8_t* data_in
return status;
}
-static bool transfer_command(uint8_t command, uint8_t* data_in, uint8_t* data_out, uint32_t data_length) {
+static bool transfer_command(uint8_t command, uint8_t *data_in, uint8_t *data_out, uint32_t data_length) {
return transfer(&command, 1, data_in, data_out, data_length);
}
@@ -77,16 +78,16 @@ bool spi_flash_command(uint8_t command) {
return transfer_command(command, NULL, NULL, 0);
}
-bool spi_flash_read_command(uint8_t command, uint8_t* data, uint32_t data_length) {
+bool spi_flash_read_command(uint8_t command, uint8_t *data, uint32_t data_length) {
return transfer_command(command, NULL, data, data_length);
}
-bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t data_length) {
+bool spi_flash_write_command(uint8_t command, uint8_t *data, uint32_t data_length) {
return transfer_command(command, data, NULL, data_length);
}
// Pack the low 24 bits of the address into a uint8_t array.
-static void address_to_bytes(uint32_t address, uint8_t* bytes) {
+static void address_to_bytes(uint32_t address, uint8_t *bytes) {
bytes[0] = (address >> 16) & 0xff;
bytes[1] = (address >> 8) & 0xff;
bytes[2] = address & 0xff;
@@ -98,7 +99,7 @@ bool spi_flash_sector_command(uint8_t command, uint32_t address) {
return transfer(request, 4, NULL, NULL, 0);
}
-bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t data_length) {
+bool spi_flash_write_data(uint32_t address, uint8_t *data, uint32_t data_length) {
uint8_t request[4] = {CMD_PAGE_PROGRAM, 0x00, 0x00, 0x00};
// Write the SPI flash write address into the bytes following the command byte.
address_to_bytes(address, request + 1);
@@ -112,7 +113,7 @@ bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t data_length)
return status;
}
-bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t data_length) {
+bool spi_flash_read_data(uint32_t address, uint8_t *data, uint32_t data_length) {
uint8_t request[5] = {CMD_READ_DATA, 0x00, 0x00, 0x00};
uint8_t command_length = 4;
if (flash_device->supports_fast_read) {
@@ -145,7 +146,7 @@ void spi_flash_init(void) {
common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus);
}
-void spi_flash_init_device(const external_flash_device* device) {
+void spi_flash_init_device(const external_flash_device *device) {
flash_device = device;
spi_flash_baudrate = device->max_clock_speed_mhz * 1000000;
if (spi_flash_baudrate > SPI_FLASH_MAX_BAUDRATE) {
diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c
index 09b30b6ba..874f25821 100644
--- a/supervisor/shared/filesystem.c
+++ b/supervisor/shared/filesystem.c
@@ -75,7 +75,7 @@ static void make_sample_code_file(FATFS *fatfs) {
FIL fs;
UINT char_written = 0;
const byte buffer[] = "print(\"Hello World!\")\n";
- //Create or modify existing code.py file
+ // Create or modify existing code.py file
f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS);
f_write(&fs, buffer, sizeof(buffer) - 1, &char_written);
f_close(&fs);
@@ -106,11 +106,11 @@ void filesystem_init(bool create_allowed, bool force_create) {
}
// set label
-#ifdef CIRCUITPY_DRIVE_LABEL
+ #ifdef CIRCUITPY_DRIVE_LABEL
res = f_setlabel(&vfs_fat->fatfs, CIRCUITPY_DRIVE_LABEL);
-#else
+ #else
res = f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
-#endif
+ #endif
if (res != FR_OK) {
return;
}
diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c
index 1e09fe14b..33314adf1 100644
--- a/supervisor/shared/flash.c
+++ b/supervisor/shared/flash.c
@@ -160,7 +160,7 @@ STATIC mp_obj_t supervisor_flash_obj_writeblocks(mp_obj_t self, mp_obj_t block_n
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(supervisor_flash_obj_writeblocks_obj, supervisor_flash_obj_writeblocks);
-bool flash_ioctl(size_t cmd, mp_int_t* out_value) {
+bool flash_ioctl(size_t cmd, mp_int_t *out_value) {
*out_value = 0;
switch (cmd) {
case BP_IOCTL_INIT:
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c
index 480c322b0..83c9d6323 100755..100644
--- a/supervisor/shared/memory.c
+++ b/supervisor/shared/memory.c
@@ -34,32 +34,32 @@
enum {
CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT =
- // stack + heap
- 2
-#ifdef EXTERNAL_FLASH_DEVICES
- + 1
-#endif
-#if CIRCUITPY_USB_MIDI
- + 1
-#endif
+ // stack + heap
+ 2
+ #ifdef EXTERNAL_FLASH_DEVICES
+ + 1
+ #endif
+ #if CIRCUITPY_USB_MIDI
+ + 1
+ #endif
,
CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT =
- 0
-#if CIRCUITPY_DISPLAYIO
- #if CIRCUITPY_TERMINALIO
+ 0
+ #if CIRCUITPY_DISPLAYIO
+ #if CIRCUITPY_TERMINALIO
+ 1
- #endif
- + CIRCUITPY_DISPLAY_LIMIT * (
- // Maximum needs of one display: max(4 if RGBMATRIX, 1 if SHARPDISPLAY, 0)
- #if CIRCUITPY_RGBMATRIX
+ #endif
+ + CIRCUITPY_DISPLAY_LIMIT * (
+ // Maximum needs of one display: max(4 if RGBMATRIX, 1 if SHARPDISPLAY, 0)
+ #if CIRCUITPY_RGBMATRIX
4
- #elif CIRCUITPY_SHARPDISPLAY
+ #elif CIRCUITPY_SHARPDISPLAY
1
- #else
+ #else
0
+ #endif
+ )
#endif
- )
-#endif
,
CIRCUITPY_SUPERVISOR_ALLOC_COUNT = CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT + CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT
};
@@ -71,40 +71,38 @@ enum {
#define MOVABLE 2
static supervisor_allocation allocations[CIRCUITPY_SUPERVISOR_ALLOC_COUNT];
-supervisor_allocation* old_allocations;
+supervisor_allocation *old_allocations;
typedef struct _supervisor_allocation_node {
- struct _supervisor_allocation_node* next;
+ struct _supervisor_allocation_node *next;
size_t length;
// We use uint32_t to ensure word (4 byte) alignment.
uint32_t data[];
} supervisor_allocation_node;
-supervisor_allocation_node* low_head;
-supervisor_allocation_node* high_head;
+supervisor_allocation_node *low_head;
+supervisor_allocation_node *high_head;
// Intermediate (void*) is to suppress -Wcast-align warning. Alignment will always be correct
// because this only reverses how (alloc)->ptr was obtained as &(node->data[0]).
-#define ALLOCATION_NODE(alloc) ((supervisor_allocation_node*)(void*)((char*)((alloc)->ptr) - sizeof(supervisor_allocation_node)))
+#define ALLOCATION_NODE(alloc) ((supervisor_allocation_node *)(void *)((char *)((alloc)->ptr) - sizeof(supervisor_allocation_node)))
-void free_memory(supervisor_allocation* allocation) {
+void free_memory(supervisor_allocation *allocation) {
if (allocation == NULL || allocation->ptr == NULL) {
return;
}
- supervisor_allocation_node* node = ALLOCATION_NODE(allocation);
+ supervisor_allocation_node *node = ALLOCATION_NODE(allocation);
if (node == low_head) {
do {
low_head = low_head->next;
} while (low_head != NULL && (low_head->length & HOLE));
- }
- else if (node == high_head) {
+ } else if (node == high_head) {
do {
high_head = high_head->next;
} while (high_head != NULL && (high_head->length & HOLE));
- }
- else {
+ } else {
// Check if it's in the list of embedded allocations.
- supervisor_allocation_node** emb = &MP_STATE_VM(first_embedded_allocation);
+ supervisor_allocation_node **emb = &MP_STATE_VM(first_embedded_allocation);
while (*emb != NULL && *emb != node) {
emb = &((*emb)->next);
}
@@ -112,12 +110,11 @@ void free_memory(supervisor_allocation* allocation) {
// Found, remove it from the list.
*emb = node->next;
m_free(node
-#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
+ #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
, sizeof(supervisor_allocation_node) + (node->length & ~FLAGS)
-#endif
- );
- }
- else {
+ #endif
+ );
+ } else {
// Else it must be within the low or high ranges and becomes a hole.
node->length = ((node->length & ~FLAGS) | HOLE);
}
@@ -125,11 +122,11 @@ void free_memory(supervisor_allocation* allocation) {
allocation->ptr = NULL;
}
-supervisor_allocation* allocation_from_ptr(void *ptr) {
+supervisor_allocation *allocation_from_ptr(void *ptr) {
// When called from the context of supervisor_move_memory() (old_allocations != NULL), search
// by old pointer to give clients a way of mapping from old to new pointer. But not if
// ptr == NULL, then the caller wants an allocation whose current ptr is NULL.
- supervisor_allocation* list = (old_allocations && ptr) ? old_allocations : &allocations[0];
+ supervisor_allocation *list = (old_allocations && ptr) ? old_allocations : &allocations[0];
for (size_t index = 0; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) {
if (list[index].ptr == ptr) {
return &allocations[index];
@@ -138,11 +135,11 @@ supervisor_allocation* allocation_from_ptr(void *ptr) {
return NULL;
}
-supervisor_allocation* allocate_remaining_memory(void) {
+supervisor_allocation *allocate_remaining_memory(void) {
return allocate_memory((uint32_t)-1, false, false);
}
-static supervisor_allocation_node* find_hole(supervisor_allocation_node* node, size_t length) {
+static supervisor_allocation_node *find_hole(supervisor_allocation_node *node, size_t length) {
for (; node != NULL; node = node->next) {
if (node->length == (length | HOLE)) {
break;
@@ -151,15 +148,15 @@ static supervisor_allocation_node* find_hole(supervisor_allocation_node* node, s
return node;
}
-static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool high, bool movable) {
+static supervisor_allocation_node *allocate_memory_node(uint32_t length, bool high, bool movable) {
if (CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT == 0) {
assert(!movable);
}
// supervisor_move_memory() currently does not support movable allocations on the high side, it
// must be extended first if this is ever needed.
assert(!(high && movable));
- uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom();
- uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top();
+ uint32_t *low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom();
+ uint32_t *high_address = high_head ? (uint32_t *)high_head : port_heap_get_top();
// Special case for allocate_remaining_memory(), avoids computing low/high_address twice.
if (length == (uint32_t)-1) {
length = (high_address - low_address) * 4 - sizeof(supervisor_allocation_node);
@@ -168,23 +165,21 @@ static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool hi
return NULL;
}
// 1. Matching hole on the requested side?
- supervisor_allocation_node* node = find_hole(high ? high_head : low_head, length);
+ supervisor_allocation_node *node = find_hole(high ? high_head : low_head, length);
if (!node) {
// 2. Enough free space in the middle?
if ((high_address - low_address) * 4 >= (int32_t)(sizeof(supervisor_allocation_node) + length)) {
if (high) {
high_address -= (sizeof(supervisor_allocation_node) + length) / 4;
- node = (supervisor_allocation_node*)high_address;
+ node = (supervisor_allocation_node *)high_address;
node->next = high_head;
high_head = node;
- }
- else {
- node = (supervisor_allocation_node*)low_address;
+ } else {
+ node = (supervisor_allocation_node *)low_address;
node->next = low_head;
low_head = node;
}
- }
- else {
+ } else {
// 3. Matching hole on the other side?
node = find_hole(high ? low_head : high_head, length);
if (!node) {
@@ -210,13 +205,13 @@ static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool hi
return node;
}
-supervisor_allocation* allocate_memory(uint32_t length, bool high, bool movable) {
- supervisor_allocation_node* node = allocate_memory_node(length, high, movable);
+supervisor_allocation *allocate_memory(uint32_t length, bool high, bool movable) {
+ supervisor_allocation_node *node = allocate_memory_node(length, high, movable);
if (!node) {
return NULL;
}
// Find the first free allocation.
- supervisor_allocation* alloc = allocation_from_ptr(NULL);
+ supervisor_allocation *alloc = allocation_from_ptr(NULL);
if (!alloc) {
// We should free node again to avoid leaking, but something is wrong anyway if clients try
// to make more allocations than available, so don't bother.
@@ -226,7 +221,7 @@ supervisor_allocation* allocate_memory(uint32_t length, bool high, bool movable)
return alloc;
}
-size_t get_allocation_length(supervisor_allocation* allocation) {
+size_t get_allocation_length(supervisor_allocation *allocation) {
return ALLOCATION_NODE(allocation)->length & ~FLAGS;
}
@@ -250,19 +245,19 @@ void supervisor_move_memory(void) {
bool acted;
do {
acted = false;
- supervisor_allocation_node** nodep = &low_head;
+ supervisor_allocation_node **nodep = &low_head;
while (*nodep != NULL && (*nodep)->next != NULL) {
if (((*nodep)->length & MOVABLE) && ((*nodep)->next->length & HOLE)) {
- supervisor_allocation_node* oldnode = *nodep;
- supervisor_allocation_node* start = oldnode->next;
- supervisor_allocation* alloc = allocation_from_ptr(&(oldnode->data[0]));
+ supervisor_allocation_node *oldnode = *nodep;
+ supervisor_allocation_node *start = oldnode->next;
+ supervisor_allocation *alloc = allocation_from_ptr(&(oldnode->data[0]));
assert(alloc != NULL);
alloc->ptr = &(start->data[0]);
oldnode->next = start->next;
size_t holelength = start->length;
size_t size = sizeof(supervisor_allocation_node) + (oldnode->length & ~FLAGS);
memmove(start, oldnode, size);
- supervisor_allocation_node* newhole = (supervisor_allocation_node*)(void*)((char*)start + size);
+ supervisor_allocation_node *newhole = (supervisor_allocation_node *)(void *)((char *)start + size);
newhole->next = start;
newhole->length = holelength;
*nodep = newhole;
@@ -274,7 +269,8 @@ void supervisor_move_memory(void) {
// Any holes bubbled to the top can be absorbed into the free middle.
while (low_head != NULL && (low_head->length & HOLE)) {
low_head = low_head->next;
- };
+ }
+ ;
// Don't bother compacting the high side, there are no movable allocations and no holes there in
// current usage.
@@ -287,23 +283,23 @@ void supervisor_move_memory(void) {
// code than using the qsort() function from the C library.
while (MP_STATE_VM(first_embedded_allocation)) {
// First element is first candidate.
- supervisor_allocation_node** pminnode = &MP_STATE_VM(first_embedded_allocation);
+ supervisor_allocation_node **pminnode = &MP_STATE_VM(first_embedded_allocation);
// Iterate from second element (if any) on.
- for (supervisor_allocation_node** pnode = &(MP_STATE_VM(first_embedded_allocation)->next); *pnode != NULL; pnode = &(*pnode)->next) {
+ for (supervisor_allocation_node **pnode = &(MP_STATE_VM(first_embedded_allocation)->next); *pnode != NULL; pnode = &(*pnode)->next) {
if (*pnode < *pminnode) {
pminnode = pnode;
}
}
// Remove from list.
- supervisor_allocation_node* node = *pminnode;
+ supervisor_allocation_node *node = *pminnode;
*pminnode = node->next;
// Process.
size_t length = (node->length & ~FLAGS);
- supervisor_allocation* alloc = allocation_from_ptr(&(node->data[0]));
+ supervisor_allocation *alloc = allocation_from_ptr(&(node->data[0]));
assert(alloc != NULL);
// This may overwrite the header of node if it happened to be there already, but not the
// data.
- supervisor_allocation_node* new_node = allocate_memory_node(length, false, true);
+ supervisor_allocation_node *new_node = allocate_memory_node(length, false, true);
// There must be enough free space.
assert(new_node != NULL);
memmove(&(new_node->data[0]), &(node->data[0]), length);
diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c
index bbc4807f9..c68c4bf7e 100644
--- a/supervisor/shared/micropython.c
+++ b/supervisor/shared/micropython.c
@@ -44,7 +44,7 @@
int mp_hal_stdin_rx_chr(void) {
for (;;) {
#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP
#endif
mp_handle_pending();
if (serial_bytes_available()) {
diff --git a/supervisor/shared/rgb_led_colors.h b/supervisor/shared/rgb_led_colors.h
index c723fbab3..581c17744 100644
--- a/supervisor/shared/rgb_led_colors.h
+++ b/supervisor/shared/rgb_led_colors.h
@@ -9,7 +9,7 @@
#define BLUE COLOR(0, 0, INTENSITY)
#define CYAN COLOR(0, INTENSITY, INTENSITY)
#define RED COLOR(INTENSITY, 0, 0)
-#define ORANGE COLOR(INTENSITY, INTENSITY*2/3, 0)
+#define ORANGE COLOR(INTENSITY, INTENSITY * 2 / 3, 0)
#define YELLOW COLOR(INTENSITY, INTENSITY, 0)
#define PURPLE COLOR(INTENSITY, 0, INTENSITY)
#define WHITE COLOR(INTENSITY, INTENSITY, INTENSITY)
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c
index 60470e057..d6e11c2ae 100644
--- a/supervisor/shared/rgb_led_status.c
+++ b/supervisor/shared/rgb_led_status.c
@@ -104,43 +104,43 @@ void rgb_led_status_init() {
rgb_led_status_init_in_progress = true;
#ifdef MICROPY_HW_NEOPIXEL
- common_hal_digitalio_digitalinout_construct(&status_neopixel, MICROPY_HW_NEOPIXEL);
- // Pretend we aren't using the pins. digitalio.DigitalInOut
- // will mark them as used.
- neopixel_in_use = false;
- common_hal_digitalio_digitalinout_switch_to_output(&status_neopixel, false, DRIVE_MODE_PUSH_PULL);
+ common_hal_digitalio_digitalinout_construct(&status_neopixel, MICROPY_HW_NEOPIXEL);
+ // Pretend we aren't using the pins. digitalio.DigitalInOut
+ // will mark them as used.
+ neopixel_in_use = false;
+ common_hal_digitalio_digitalinout_switch_to_output(&status_neopixel, false, DRIVE_MODE_PUSH_PULL);
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
- #if CIRCUITPY_BITBANG_APA102
- shared_module_bitbangio_spi_construct(&status_apa102,
- MICROPY_HW_APA102_SCK,
- MICROPY_HW_APA102_MOSI,
- NULL);
- #else
- if (!common_hal_busio_spi_deinited(&status_apa102)) {
- // This may call us recursively if common_hal_reset_pin() is called,
- // The rgb_led_status_init_in_progress guard will prevent further recursion.
- common_hal_busio_spi_deinit(&status_apa102);
- }
- common_hal_busio_spi_construct(&status_apa102,
- MICROPY_HW_APA102_SCK,
- MICROPY_HW_APA102_MOSI,
- NULL);
- common_hal_busio_spi_never_reset(&status_apa102);
- #endif
- // Pretend we aren't using the pins. bitbangio.SPI will
- // mark them as used.
- apa102_mosi_in_use = false;
- apa102_sck_in_use = false;
- #if CIRCUITPY_BITBANG_APA102
- shared_module_bitbangio_spi_try_lock(&status_apa102);
- // Use 1MHz for clock rate. Some APA102's are spec'd 800kHz-1200kHz,
- // though many can run much faster. bitbang will probably run slower.
- shared_module_bitbangio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
- #else
- common_hal_busio_spi_try_lock(&status_apa102);
- common_hal_busio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
- #endif
+ #if CIRCUITPY_BITBANG_APA102
+ shared_module_bitbangio_spi_construct(&status_apa102,
+ MICROPY_HW_APA102_SCK,
+ MICROPY_HW_APA102_MOSI,
+ NULL);
+ #else
+ if (!common_hal_busio_spi_deinited(&status_apa102)) {
+ // This may call us recursively if common_hal_reset_pin() is called,
+ // The rgb_led_status_init_in_progress guard will prevent further recursion.
+ common_hal_busio_spi_deinit(&status_apa102);
+ }
+ common_hal_busio_spi_construct(&status_apa102,
+ MICROPY_HW_APA102_SCK,
+ MICROPY_HW_APA102_MOSI,
+ NULL);
+ common_hal_busio_spi_never_reset(&status_apa102);
+ #endif
+ // Pretend we aren't using the pins. bitbangio.SPI will
+ // mark them as used.
+ apa102_mosi_in_use = false;
+ apa102_sck_in_use = false;
+ #if CIRCUITPY_BITBANG_APA102
+ shared_module_bitbangio_spi_try_lock(&status_apa102);
+ // Use 1MHz for clock rate. Some APA102's are spec'd 800kHz-1200kHz,
+ // though many can run much faster. bitbang will probably run slower.
+ shared_module_bitbangio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
+ #else
+ common_hal_busio_spi_try_lock(&status_apa102);
+ common_hal_busio_spi_configure(&status_apa102, 1000000, 0, 0, 8);
+ #endif
#endif
@@ -182,14 +182,14 @@ void rgb_led_status_init() {
void reset_status_led() {
#ifdef MICROPY_HW_NEOPIXEL
- common_hal_reset_pin(MICROPY_HW_NEOPIXEL);
+ common_hal_reset_pin(MICROPY_HW_NEOPIXEL);
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
- common_hal_reset_pin(MICROPY_HW_APA102_MOSI);
- common_hal_reset_pin(MICROPY_HW_APA102_SCK);
+ common_hal_reset_pin(MICROPY_HW_APA102_MOSI);
+ common_hal_reset_pin(MICROPY_HW_APA102_SCK);
#endif
#if defined(CP_RGB_STATUS_LED)
- // TODO: Support sharing status LED with user.
+ // TODO: Support sharing status LED with user.
#endif
}
@@ -203,132 +203,132 @@ void new_status_color(uint32_t rgb) {
#endif
#ifdef MICROPY_HW_NEOPIXEL
- if (neopixel_in_use) {
- return;
- }
- status_neopixel_color[0] = (rgb_adjusted >> 8) & 0xff;
- status_neopixel_color[1] = (rgb_adjusted >> 16) & 0xff;
- status_neopixel_color[2] = rgb_adjusted & 0xff;
- common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3);
+ if (neopixel_in_use) {
+ return;
+ }
+ status_neopixel_color[0] = (rgb_adjusted >> 8) & 0xff;
+ status_neopixel_color[1] = (rgb_adjusted >> 16) & 0xff;
+ status_neopixel_color[2] = rgb_adjusted & 0xff;
+ common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3);
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
- if (apa102_mosi_in_use || apa102_sck_in_use) {
- return;
- }
- status_apa102_color[5] = rgb_adjusted & 0xff;
- status_apa102_color[6] = (rgb_adjusted >> 8) & 0xff;
- status_apa102_color[7] = (rgb_adjusted >> 16) & 0xff;
-
- #if CIRCUITPY_BITBANG_APA102
- shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
- #else
- common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
- #endif
+ if (apa102_mosi_in_use || apa102_sck_in_use) {
+ return;
+ }
+ status_apa102_color[5] = rgb_adjusted & 0xff;
+ status_apa102_color[6] = (rgb_adjusted >> 8) & 0xff;
+ status_apa102_color[7] = (rgb_adjusted >> 16) & 0xff;
+
+ #if CIRCUITPY_BITBANG_APA102
+ shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
+ #else
+ common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
+ #endif
#endif
#if defined(CP_RGB_STATUS_LED)
- uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
- uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
- uint8_t blue_u8 = rgb_adjusted & 0xFF;
-
- #if defined(CP_RGB_STATUS_INVERTED_PWM)
- status_rgb_color[0] = (1 << 16) - 1 - ((uint16_t) (red_u8 << 8) + red_u8);
- status_rgb_color[1] = (1 << 16) - 1 - ((uint16_t) (green_u8 << 8) + green_u8);
- status_rgb_color[2] = (1 << 16) - 1 - ((uint16_t) (blue_u8 << 8) + blue_u8);
+ uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
+ uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
+ uint8_t blue_u8 = rgb_adjusted & 0xFF;
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ status_rgb_color[0] = (1 << 16) - 1 - ((uint16_t)(red_u8 << 8) + red_u8);
+ status_rgb_color[1] = (1 << 16) - 1 - ((uint16_t)(green_u8 << 8) + green_u8);
+ status_rgb_color[2] = (1 << 16) - 1 - ((uint16_t)(blue_u8 << 8) + blue_u8);
#else
- status_rgb_color[0] = (uint16_t) (red_u8 << 8) + red_u8;
- status_rgb_color[1] = (uint16_t) (green_u8 << 8) + green_u8;
- status_rgb_color[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
- #endif
-
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, status_rgb_color[0]);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, status_rgb_color[1]);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, status_rgb_color[2]);
+ status_rgb_color[0] = (uint16_t)(red_u8 << 8) + red_u8;
+ status_rgb_color[1] = (uint16_t)(green_u8 << 8) + green_u8;
+ status_rgb_color[2] = (uint16_t)(blue_u8 << 8) + blue_u8;
+ #endif
+
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, status_rgb_color[0]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, status_rgb_color[1]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, status_rgb_color[2]);
#endif
}
void temp_status_color(uint32_t rgb) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
- uint32_t rgb_adjusted = rgb;
- rgb_adjusted = color_brightness(rgb, rgb_status_brightness);
+ uint32_t rgb_adjusted = rgb;
+ rgb_adjusted = color_brightness(rgb, rgb_status_brightness);
#endif
#ifdef MICROPY_HW_NEOPIXEL
- if (neopixel_in_use) {
- return;
- }
- uint8_t colors[3] = {(rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, rgb_adjusted & 0xff};
- common_hal_neopixel_write(&status_neopixel, colors, 3);
+ if (neopixel_in_use) {
+ return;
+ }
+ uint8_t colors[3] = {(rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, rgb_adjusted & 0xff};
+ common_hal_neopixel_write(&status_neopixel, colors, 3);
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
- if (apa102_mosi_in_use || apa102_sck_in_use) {
- return;
- }
- uint8_t colors[APA102_BUFFER_LENGTH] = {0, 0, 0, 0, 0xff, rgb_adjusted & 0xff, (rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, 0xff, 0xff, 0xff, 0xff};
- #if CIRCUITPY_BITBANG_APA102
- shared_module_bitbangio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
- #else
- common_hal_busio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
- #endif
+ if (apa102_mosi_in_use || apa102_sck_in_use) {
+ return;
+ }
+ uint8_t colors[APA102_BUFFER_LENGTH] = {0, 0, 0, 0, 0xff, rgb_adjusted & 0xff, (rgb_adjusted >> 8) & 0xff, (rgb_adjusted >> 16) & 0xff, 0xff, 0xff, 0xff, 0xff};
+ #if CIRCUITPY_BITBANG_APA102
+ shared_module_bitbangio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
+ #else
+ common_hal_busio_spi_write(&status_apa102, colors, APA102_BUFFER_LENGTH);
+ #endif
#endif
#if defined(CP_RGB_STATUS_LED)
- uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
- uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
- uint8_t blue_u8 = rgb_adjusted & 0xFF;
-
- uint16_t temp_status_color_rgb[3] = {0};
-
- #if defined(CP_RGB_STATUS_INVERTED_PWM)
- temp_status_color_rgb[0] = (1 << 16) - 1 - ((uint16_t) (red_u8 << 8) + red_u8);
- temp_status_color_rgb[1] = (1 << 16) - 1 - ((uint16_t) (green_u8 << 8) + green_u8);
- temp_status_color_rgb[2] = (1 << 16) - 1 - ((uint16_t) (blue_u8 << 8) + blue_u8);
- #else
- temp_status_color_rgb[0] = (uint16_t) (red_u8 << 8) + red_u8;
- temp_status_color_rgb[1] = (uint16_t) (green_u8 << 8) + green_u8;
- temp_status_color_rgb[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
+ uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
+ uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
+ uint8_t blue_u8 = rgb_adjusted & 0xFF;
+
+ uint16_t temp_status_color_rgb[3] = {0};
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ temp_status_color_rgb[0] = (1 << 16) - 1 - ((uint16_t)(red_u8 << 8) + red_u8);
+ temp_status_color_rgb[1] = (1 << 16) - 1 - ((uint16_t)(green_u8 << 8) + green_u8);
+ temp_status_color_rgb[2] = (1 << 16) - 1 - ((uint16_t)(blue_u8 << 8) + blue_u8);
+ #else
+ temp_status_color_rgb[0] = (uint16_t)(red_u8 << 8) + red_u8;
+ temp_status_color_rgb[1] = (uint16_t)(green_u8 << 8) + green_u8;
+ temp_status_color_rgb[2] = (uint16_t)(blue_u8 << 8) + blue_u8;
#endif
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, temp_status_color_rgb[0]);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, temp_status_color_rgb[1]);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, temp_status_color_rgb[2]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, temp_status_color_rgb[0]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, temp_status_color_rgb[1]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, temp_status_color_rgb[2]);
#endif
}
void clear_temp_status() {
#ifdef MICROPY_HW_NEOPIXEL
- if (neopixel_in_use) {
- return;
- }
- common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3);
+ if (neopixel_in_use) {
+ return;
+ }
+ common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3);
#endif
#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
- if (apa102_mosi_in_use || apa102_sck_in_use) {
- return;
- }
- #if CIRCUITPY_BITBANG_APA102
- shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
- #else
- common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
- #endif
+ if (apa102_mosi_in_use || apa102_sck_in_use) {
+ return;
+ }
+ #if CIRCUITPY_BITBANG_APA102
+ shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
+ #else
+ common_hal_busio_spi_write(&status_apa102, status_apa102_color, APA102_BUFFER_LENGTH);
+ #endif
#endif
#if defined(CP_RGB_STATUS_LED)
- uint16_t red = 0;
- uint16_t green = 0;
- uint16_t blue = 0;
-
- #if defined(CP_RGB_STATUS_INVERTED_PWM)
- red = (1 << 16) - 1 - status_rgb_color[0];
- green = (1 << 16) - 1 - status_rgb_color[1];
- blue = (1 << 16) - 1 - status_rgb_color[2];
- #else
- red = status_rgb_color[0];
- green = status_rgb_color[1];
- blue = status_rgb_color[2];
- #endif
-
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, red);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, green);
- common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, blue);
+ uint16_t red = 0;
+ uint16_t green = 0;
+ uint16_t blue = 0;
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ red = (1 << 16) - 1 - status_rgb_color[0];
+ green = (1 << 16) - 1 - status_rgb_color[1];
+ blue = (1 << 16) - 1 - status_rgb_color[2];
+ #else
+ red = status_rgb_color[0];
+ green = status_rgb_color[1];
+ blue = status_rgb_color[2];
+ #endif
+
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, red);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, green);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, blue);
#endif
}
@@ -343,7 +343,7 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness) {
#endif
}
-void set_rgb_status_brightness(uint8_t level){
+void set_rgb_status_brightness(uint8_t level) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
rgb_status_brightness = level;
uint32_t current_color = current_status_color;
@@ -355,10 +355,10 @@ void set_rgb_status_brightness(uint8_t level){
#endif
}
-void prep_rgb_status_animation(const pyexec_result_t* result,
- bool found_main,
- safe_mode_t safe_mode,
- rgb_status_animation_t* status) {
+void prep_rgb_status_animation(const pyexec_result_t *result,
+ bool found_main,
+ safe_mode_t safe_mode,
+ rgb_status_animation_t *status) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
new_status_color(ALL_DONE);
status->pattern_start = supervisor_ticks_ms32();
@@ -410,7 +410,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
#endif
}
-bool tick_rgb_status_animation(rgb_status_animation_t* status) {
+bool tick_rgb_status_animation(rgb_status_animation_t *status) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
uint32_t tick_diff = supervisor_ticks_ms32() - status->pattern_start;
if (status->ok) {
@@ -442,12 +442,12 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) {
} else {
new_status_color(BOOT_RUNNING);
}
- // Next flash the exception color.
+ // Next flash the exception color.
} else if (tick_diff < EXCEPTION_TYPE_LENGTH_MS * 2) {
new_status_color(status->exception_color);
- // Finally flash the line number digits from highest to lowest.
- // Zeroes will not produce a flash but can be read by the absence of
- // a color from the sequence.
+ // Finally flash the line number digits from highest to lowest.
+ // Zeroes will not produce a flash but can be read by the absence of
+ // a color from the sequence.
} else if (tick_diff < (EXCEPTION_TYPE_LENGTH_MS * 2 + LINE_NUMBER_TOGGLE_LENGTH * status->digit_sum)) {
uint32_t digit_diff = tick_diff - EXCEPTION_TYPE_LENGTH_MS * 2;
if ((digit_diff % LINE_NUMBER_TOGGLE_LENGTH) < (LINE_NUMBER_TOGGLE_LENGTH / 2)) {
diff --git a/supervisor/shared/rgb_led_status.h b/supervisor/shared/rgb_led_status.h
index 84c97796a..753a1167c 100644
--- a/supervisor/shared/rgb_led_status.h
+++ b/supervisor/shared/rgb_led_status.h
@@ -72,10 +72,10 @@ typedef struct {
bool found_main;
} rgb_status_animation_t;
-void prep_rgb_status_animation(const pyexec_result_t* result,
- bool found_main,
- safe_mode_t safe_mode,
- rgb_status_animation_t* status);
-bool tick_rgb_status_animation(rgb_status_animation_t* status);
+void prep_rgb_status_animation(const pyexec_result_t *result,
+ bool found_main,
+ safe_mode_t safe_mode,
+ rgb_status_animation_t *status);
+bool tick_rgb_status_animation(rgb_status_animation_t *status);
#endif // MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H
diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c
index 5d3b416f1..e8778216a 100644
--- a/supervisor/shared/safe_mode.c
+++ b/supervisor/shared/safe_mode.c
@@ -85,7 +85,7 @@ safe_mode_t wait_for_safe_mode_reset(void) {
#endif
#ifdef CIRCUITPY_BOOT_BUTTON
if (!common_hal_digitalio_digitalinout_get_value(&boot_button)) {
- return USER_SAFE_MODE;
+ return USER_SAFE_MODE;
}
#endif
diff = supervisor_ticks_ms64() - start_ticks;
@@ -128,13 +128,13 @@ void print_safe_mode_message(safe_mode_t reason) {
switch (reason) {
case USER_SAFE_MODE:
#ifdef BOARD_USER_SAFE_MODE_ACTION
- // Output a user safe mode string if it's set.
- serial_write_compressed(translate("You requested starting safe mode by "));
- serial_write_compressed(BOARD_USER_SAFE_MODE_ACTION);
- serial_write_compressed(translate("To exit, please reset the board without "));
- serial_write_compressed(BOARD_USER_SAFE_MODE_ACTION);
+ // Output a user safe mode string if it's set.
+ serial_write_compressed(translate("You requested starting safe mode by "));
+ serial_write_compressed(BOARD_USER_SAFE_MODE_ACTION);
+ serial_write_compressed(translate("To exit, please reset the board without "));
+ serial_write_compressed(BOARD_USER_SAFE_MODE_ACTION);
#else
- break;
+ break;
#endif
return;
case MANUAL_SAFE_MODE:
@@ -178,13 +178,13 @@ void print_safe_mode_message(safe_mode_t reason) {
case GC_ALLOC_OUTSIDE_VM:
serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running."));
break;
- #ifdef SOFTDEVICE_PRESENT
+ #ifdef SOFTDEVICE_PRESENT
// defined in ports/nrf/bluetooth/bluetooth_common.mk
// will print "Unknown reason" if somehow encountered on other ports
case NORDIC_SOFT_DEVICE_ASSERT:
serial_write_compressed(translate("Nordic Soft Device failure assertion."));
break;
- #endif
+ #endif
case FLASH_WRITE_FAIL:
serial_write_compressed(translate("Failed to write internal flash."));
break;
diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h
index 34fc3c8ae..722e97033 100644
--- a/supervisor/shared/safe_mode.h
+++ b/supervisor/shared/safe_mode.h
@@ -30,21 +30,21 @@
#include "py/mpconfig.h"
typedef enum {
- NO_SAFE_MODE = 0,
- BROWNOUT,
- HARD_CRASH,
- USER_SAFE_MODE,
- HEAP_OVERWRITTEN,
- MANUAL_SAFE_MODE,
- MICROPY_NLR_JUMP_FAIL,
- MICROPY_FATAL_ERROR,
- GC_ALLOC_OUTSIDE_VM,
- PROGRAMMATIC_SAFE_MODE,
- NORDIC_SOFT_DEVICE_ASSERT,
- FLASH_WRITE_FAIL,
- MEM_MANAGE,
- WATCHDOG_RESET,
- NO_HEAP,
+ NO_SAFE_MODE = 0,
+ BROWNOUT,
+ HARD_CRASH,
+ USER_SAFE_MODE,
+ HEAP_OVERWRITTEN,
+ MANUAL_SAFE_MODE,
+ MICROPY_NLR_JUMP_FAIL,
+ MICROPY_FATAL_ERROR,
+ GC_ALLOC_OUTSIDE_VM,
+ PROGRAMMATIC_SAFE_MODE,
+ NORDIC_SOFT_DEVICE_ASSERT,
+ FLASH_WRITE_FAIL,
+ MEM_MANAGE,
+ WATCHDOG_RESET,
+ NO_HEAP,
} safe_mode_t;
safe_mode_t wait_for_safe_mode_reset(void);
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c
index 9cc12de51..268cebdbb 100644
--- a/supervisor/shared/serial.c
+++ b/supervisor/shared/serial.c
@@ -52,17 +52,17 @@ bool tud_vendor_connected(void);
#endif
void serial_early_init(void) {
-#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
+ #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
debug_uart.base.type = &busio_uart_type;
- const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(DEBUG_UART_RX);
- const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEBUG_UART_TX);
+ const mcu_pin_obj_t *rx = MP_OBJ_TO_PTR(DEBUG_UART_RX);
+ const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(DEBUG_UART_TX);
common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL,
- false, 115200, 8, UART_PARITY_NONE, 1, 1.0f, 64,
- buf_array, true);
+ false, 115200, 8, UART_PARITY_NONE, 1, 1.0f, 64,
+ buf_array, true);
common_hal_busio_uart_never_reset(&debug_uart);
-#endif
+ #endif
}
void serial_init(void) {
@@ -70,68 +70,68 @@ void serial_init(void) {
}
bool serial_connected(void) {
-#if CIRCUITPY_USB_VENDOR
+ #if CIRCUITPY_USB_VENDOR
if (tud_vendor_connected()) {
return true;
}
-#endif
+ #endif
-#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
+ #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
return true;
-#else
+ #else
return tud_cdc_connected();
-#endif
+ #endif
}
char serial_read(void) {
-#if CIRCUITPY_USB_VENDOR
+ #if CIRCUITPY_USB_VENDOR
if (tud_vendor_connected() && tud_vendor_available() > 0) {
char tiny_buffer;
tud_vendor_read(&tiny_buffer, 1);
return tiny_buffer;
}
-#endif
+ #endif
-#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
+ #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
if (tud_cdc_connected() && tud_cdc_available() > 0) {
- return (char) tud_cdc_read_char();
+ return (char)tud_cdc_read_char();
}
int uart_errcode;
char text;
- common_hal_busio_uart_read(&debug_uart, (uint8_t*) &text, 1, &uart_errcode);
+ common_hal_busio_uart_read(&debug_uart, (uint8_t *)&text, 1, &uart_errcode);
return text;
-#else
- return (char) tud_cdc_read_char();
-#endif
+ #else
+ return (char)tud_cdc_read_char();
+ #endif
}
bool serial_bytes_available(void) {
-#if CIRCUITPY_USB_VENDOR
+ #if CIRCUITPY_USB_VENDOR
if (tud_vendor_connected() && tud_vendor_available() > 0) {
return true;
}
-#endif
+ #endif
-#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
+ #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0);
-#else
+ #else
return tud_cdc_available() > 0;
-#endif
+ #endif
}
-void serial_write_substring(const char* text, uint32_t length) {
+void serial_write_substring(const char *text, uint32_t length) {
if (length == 0) {
return;
}
-#if CIRCUITPY_TERMINALIO
+ #if CIRCUITPY_TERMINALIO
int errcode;
- common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode);
-#endif
+ common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t *)text, length, &errcode);
+ #endif
-#if CIRCUITPY_USB_VENDOR
+ #if CIRCUITPY_USB_VENDOR
if (tud_vendor_connected()) {
tud_vendor_write(text, length);
}
-#endif
+ #endif
uint32_t count = 0;
while (count < length && tud_cdc_connected()) {
@@ -139,12 +139,12 @@ void serial_write_substring(const char* text, uint32_t length) {
usb_background();
}
-#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
+ #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
int uart_errcode;
- common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode);
-#endif
+ common_hal_busio_uart_write(&debug_uart, (const uint8_t *)text, length, &uart_errcode);
+ #endif
}
-void serial_write(const char* text) {
+void serial_write(const char *text) {
serial_write_substring(text, strlen(text));
}
diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c
index afea20401..f3077b46c 100755..100644
--- a/supervisor/shared/stack.c
+++ b/supervisor/shared/stack.c
@@ -38,7 +38,7 @@ extern uint32_t _estack;
static uint32_t next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE;
static uint32_t current_stack_size = 0;
// Actual location and size, may be larger than requested.
-static uint32_t* stack_limit = NULL;
+static uint32_t *stack_limit = NULL;
static size_t stack_length = 0;
#define EXCEPTION_STACK_SIZE 1024
@@ -47,14 +47,14 @@ void allocate_stack(void) {
if (port_has_fixed_stack()) {
stack_limit = port_stack_get_limit();
- stack_length = (port_stack_get_top() - stack_limit)*sizeof(uint32_t);
+ stack_length = (port_stack_get_top() - stack_limit) * sizeof(uint32_t);
current_stack_size = stack_length;
} else {
mp_uint_t regs[10];
mp_uint_t sp = cpu_get_regs_and_sp(regs);
- mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp;
- supervisor_allocation* stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true, false);
+ mp_uint_t c_size = (uint32_t)port_stack_get_top() - sp;
+ supervisor_allocation *stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true, false);
if (stack_alloc == NULL) {
stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true, false);
current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE;
@@ -95,7 +95,7 @@ void stack_resize(void) {
allocate_stack();
}
-uint32_t* stack_get_bottom(void) {
+uint32_t *stack_get_bottom(void) {
return stack_limit;
}
diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h
index 1c75de5f7..98cc5a168 100755..100644
--- a/supervisor/shared/stack.h
+++ b/supervisor/shared/stack.h
@@ -34,7 +34,7 @@
void stack_init(void);
void stack_resize(void);
// Actual stack location and size, may be larger than requested.
-uint32_t* stack_get_bottom(void);
+uint32_t *stack_get_bottom(void);
size_t stack_get_length(void);
// Next/current requested stack size.
void set_next_stack_size(uint32_t size);
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c
index e51c48c73..f40151988 100644
--- a/supervisor/shared/tick.c
+++ b/supervisor/shared/tick.c
@@ -105,13 +105,13 @@ bool supervisor_background_tasks_ok(void) {
}
void supervisor_tick(void) {
-#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
+ #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
-#endif
-#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+ #endif
+ #ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
autoreload_tick();
-#endif
-#ifdef CIRCUITPY_GAMEPAD_TICKS
+ #endif
+ #ifdef CIRCUITPY_GAMEPAD_TICKS
if (!(port_get_raw_ticks(NULL) & CIRCUITPY_GAMEPAD_TICKS)) {
#if CIRCUITPY_GAMEPAD
gamepad_tick();
@@ -120,7 +120,7 @@ void supervisor_tick(void) {
gamepadshift_tick();
#endif
}
-#endif
+ #endif
background_callback_add(&tick_callback, supervisor_background_tasks, NULL);
}
diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c
index 8bd3c5acd..54135a493 100644
--- a/supervisor/shared/translate.c
+++ b/supervisor/shared/translate.c
@@ -37,17 +37,17 @@
#include "py/misc.h"
#include "supervisor/serial.h"
-void serial_write_compressed(const compressed_string_t* compressed) {
+void serial_write_compressed(const compressed_string_t *compressed) {
char decompressed[decompress_length(compressed)];
decompress(compressed, decompressed);
serial_write(decompressed);
}
STATIC int put_utf8(char *buf, int u) {
- if(u <= 0x7f) {
+ if (u <= 0x7f) {
*buf = u;
return 1;
- } else if(word_start <= u && u <= word_end) {
+ } else if (word_start <= u && u <= word_end) {
uint n = (u - word_start);
size_t pos = 0;
if (n > 0) {
@@ -57,25 +57,25 @@ STATIC int put_utf8(char *buf, int u) {
// note that at present, entries in the words table are
// guaranteed not to represent words themselves, so this adds
// at most 1 level of recursive call
- for(; pos < wends[n] + (n + 1) * 2; pos++) {
+ for (; pos < wends[n] + (n + 1) * 2; pos++) {
int len = put_utf8(buf, words[pos]);
buf += len;
ret += len;
}
return ret;
- } else if(u <= 0x07ff) {
+ } else if (u <= 0x07ff) {
*buf++ = 0b11000000 | (u >> 6);
- *buf = 0b10000000 | (u & 0b00111111);
+ *buf = 0b10000000 | (u & 0b00111111);
return 2;
} else { // u <= 0xffff
*buf++ = 0b11100000 | (u >> 12);
*buf++ = 0b10000000 | ((u >> 6) & 0b00111111);
- *buf = 0b10000000 | (u & 0b00111111);
+ *buf = 0b10000000 | (u & 0b00111111);
return 3;
}
}
-uint16_t decompress_length(const compressed_string_t* compressed) {
+uint16_t decompress_length(const compressed_string_t *compressed) {
if (compress_max_length_bits <= 8) {
return 1 + (compressed->data >> (8 - compress_max_length_bits));
} else {
@@ -83,7 +83,7 @@ uint16_t decompress_length(const compressed_string_t* compressed) {
}
}
-char* decompress(const compressed_string_t* compressed, char* decompressed) {
+char *decompress(const compressed_string_t *compressed, char *decompressed) {
uint8_t this_byte = compress_max_length_bits / 8;
uint8_t this_bit = 7 - compress_max_length_bits % 8;
uint8_t b = (&compressed->data)[this_byte];
@@ -118,22 +118,22 @@ char* decompress(const compressed_string_t* compressed, char* decompressed) {
i += put_utf8(decompressed + i, values[searched_length + bits - max_code]);
}
- decompressed[length-1] = '\0';
+ decompressed[length - 1] = '\0';
return decompressed;
}
inline
// gcc10 -flto has issues with this being always_inline for debug builds.
#if CIRCUITPY_DEBUG < 1
- __attribute__((always_inline))
+__attribute__((always_inline))
#endif
-const compressed_string_t* translate(const char* original) {
+const compressed_string_t *translate(const char *original) {
#ifndef NO_QSTR
#define QDEF(id, str)
#define TRANSLATION(id, firstbyte, ...) if (strcmp(original, id) == 0) { static const compressed_string_t v = { .data = firstbyte, .tail = { __VA_ARGS__ } }; return &v; } else
#include "genhdr/qstrdefs.generated.h"
- #undef TRANSLATION
- #undef QDEF
+#undef TRANSLATION
+#undef QDEF
#endif
return NULL;
}
diff --git a/supervisor/shared/translate.h b/supervisor/shared/translate.h
index 16296a416..2c440acc1 100644
--- a/supervisor/shared/translate.h
+++ b/supervisor/shared/translate.h
@@ -74,9 +74,9 @@ typedef struct {
// Return the compressed, translated version of a source string
// Usually, due to LTO, this is optimized into a load of a constant
// pointer.
-const compressed_string_t* translate(const char* c);
-void serial_write_compressed(const compressed_string_t* compressed);
-char* decompress(const compressed_string_t* compressed, char* decompressed);
-uint16_t decompress_length(const compressed_string_t* compressed);
+const compressed_string_t *translate(const char *c);
+void serial_write_compressed(const compressed_string_t *compressed);
+char *decompress(const compressed_string_t *compressed, char *decompressed);
+uint16_t decompress_length(const compressed_string_t *compressed);
#endif // MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H
diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h
index 676810119..0b23d56b9 100644
--- a/supervisor/shared/usb/tusb_config.h
+++ b/supervisor/shared/usb/tusb_config.h
@@ -41,12 +41,12 @@
#include "genhdr/autogen_usb_descriptor.h"
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// COMMON CONFIGURATION
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#endif
@@ -55,15 +55,15 @@
#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE
#endif
-//#define CFG_TUD_TASK_QUEUE_SZ 16
+// #define CFG_TUD_TASK_QUEUE_SZ 16
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// DEVICE CONFIGURATION
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
#define CFG_TUD_ENDPOINT0_SIZE 64
-//------------- CLASS -------------//
+// ------------- CLASS -------------//
// Could be 2 if secondary CDC channel requested.
#ifndef CFG_TUD_CDC
@@ -84,15 +84,15 @@
#define CFG_TUD_MSC_PRODUCT_REV "1.0"
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// USB RAM PLACEMENT
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
#define CFG_TUSB_ATTR_USBRAM
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
#ifdef __cplusplus
- }
+}
#endif
#endif /* _TUSB_CONFIG_H_ */
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index 614bf85e0..ea5faaf06 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -76,7 +76,8 @@ bool usb_enabled(void) {
return tusb_inited();
}
-MP_WEAK void post_usb_init(void) {}
+MP_WEAK void post_usb_init(void) {
+}
void usb_init(void) {
init_usb_hardware();
@@ -86,15 +87,15 @@ void usb_init(void) {
post_usb_init();
-#if MICROPY_KBD_EXCEPTION
+ #if MICROPY_KBD_EXCEPTION
// Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received
// This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
tud_cdc_set_wanted_char(CHAR_CTRL_C);
-#endif
+ #endif
-#if CIRCUITPY_USB_MIDI
+ #if CIRCUITPY_USB_MIDI
usb_midi_init();
-#endif
+ #endif
}
void usb_disconnect(void) {
@@ -111,12 +112,11 @@ void usb_background(void) {
}
static background_callback_t usb_callback;
-static void usb_background_do(void* unused) {
+static void usb_background_do(void *unused) {
usb_background();
}
-void usb_background_schedule(void)
-{
+void usb_background_schedule(void) {
background_callback_add(&usb_callback, usb_background_do, NULL);
}
@@ -125,22 +125,22 @@ void usb_irq_handler(void) {
usb_background_schedule();
}
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// tinyusb callbacks
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// Invoked when device is mounted
void tud_mount_cb(void) {
-#if CIRCUITPY_USB_MSC
+ #if CIRCUITPY_USB_MSC
usb_msc_mount();
-#endif
+ #endif
}
// Invoked when device is unmounted
void tud_umount_cb(void) {
-#if CIRCUITPY_USB_MSC
+ #if CIRCUITPY_USB_MSC
usb_msc_umount();
-#endif
+ #endif
}
// Invoked when usb bus is suspended
@@ -156,73 +156,69 @@ void tud_resume_cb(void) {
// Invoked when cdc when line state changed e.g connected/disconnected
// Use to reset to DFU when disconnect with 1200 bps
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
- (void) itf; // interface ID, not used
+ (void)itf; // interface ID, not used
// DTR = false is counted as disconnected
- if ( !dtr )
- {
+ if (!dtr) {
cdc_line_coding_t coding;
tud_cdc_get_line_coding(&coding);
- if ( coding.bit_rate == 1200 )
- {
+ if (coding.bit_rate == 1200) {
reset_to_bootloader();
}
}
}
#if CIRCUITPY_USB_VENDOR
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
// WebUSB use vendor class
-//--------------------------------------------------------------------+
+// --------------------------------------------------------------------+
-bool tud_vendor_connected(void)
-{
- return web_serial_connected;
+bool tud_vendor_connected(void) {
+ return web_serial_connected;
}
// Invoked when a control transfer occurred on an interface of this class
// Driver response accordingly to the request and the transfer stage (setup/data/ack)
// return false to stall control endpoint (e.g unsupported request)
-bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
-{
- // nothing to with DATA & ACK stage
- if (stage != CONTROL_STAGE_SETUP ) return true;
-
- switch (request->bRequest)
- {
- case VENDOR_REQUEST_WEBUSB:
- // match vendor request in BOS descriptor
- // Get landing page url
- return tud_control_xfer(rhport, request, (void*) &desc_webusb_url, desc_webusb_url.bLength);
-
- case VENDOR_REQUEST_MICROSOFT:
- if ( request->wIndex == 7 )
- {
- // Get Microsoft OS 2.0 compatible descriptor
- uint16_t total_len;
- memcpy(&total_len, desc_ms_os_20+8, 2);
-
- return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
- } else
- {
- return false;
- }
-
- case 0x22:
- // Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
- // connect and disconnect.
- web_serial_connected = (request->wValue != 0);
-
- // response with status OK
- return tud_control_status(rhport, request);
-
- default:
- // stall unknown request
- return false;
- }
-
- return true;
+bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request) {
+ // nothing to with DATA & ACK stage
+ if (stage != CONTROL_STAGE_SETUP) {
+ return true;
+ }
+
+ switch (request->bRequest)
+ {
+ case VENDOR_REQUEST_WEBUSB:
+ // match vendor request in BOS descriptor
+ // Get landing page url
+ return tud_control_xfer(rhport, request, (void *)&desc_webusb_url, desc_webusb_url.bLength);
+
+ case VENDOR_REQUEST_MICROSOFT:
+ if (request->wIndex == 7) {
+ // Get Microsoft OS 2.0 compatible descriptor
+ uint16_t total_len;
+ memcpy(&total_len, desc_ms_os_20 + 8, 2);
+
+ return tud_control_xfer(rhport, request, (void *)desc_ms_os_20, total_len);
+ } else {
+ return false;
+ }
+
+ case 0x22:
+ // Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
+ // connect and disconnect.
+ web_serial_connected = (request->wValue != 0);
+
+ // response with status OK
+ return tud_control_status(rhport, request);
+
+ default:
+ // stall unknown request
+ return false;
+ }
+
+ return true;
}
#endif // CIRCUITPY_USB_VENDOR
@@ -234,9 +230,8 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
* @param itf Interface index (for multiple cdc interfaces)
* @param wanted_char The wanted char (set previously)
*/
-void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
-{
- (void) itf; // not used
+void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
+ (void)itf; // not used
// Workaround for using lib/utils/interrupt_char.c
// Compare mp_interrupt_char with wanted_char and ignore if not matched
diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c
index b08d3b227..67df4f44b 100644
--- a/supervisor/shared/usb/usb_desc.c
+++ b/supervisor/shared/usb/usb_desc.c
@@ -31,15 +31,15 @@
// Invoked when received GET DEVICE DESCRIPTOR
// Application return pointer to descriptor
-uint8_t const * tud_descriptor_device_cb(void) {
+uint8_t const *tud_descriptor_device_cb(void) {
return usb_desc_dev;
}
// Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
- (void) index; // for multiple configurations
+uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
+ (void)index; // for multiple configurations
return usb_desc_cfg;
}
@@ -47,15 +47,15 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf) {
- (void) itf;
+uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) {
+ (void)itf;
return hid_report_descriptor;
}
#endif
// Invoked when received GET STRING DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
-uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
- uint8_t const max_index = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]);
+uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
+ uint8_t const max_index = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]);
return (index < max_index) ? string_desc_arr[index] : NULL;
}
diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c
index 7532b6aea..409bf0ea6 100644
--- a/supervisor/shared/usb/usb_msc_flash.c
+++ b/supervisor/shared/usb/usb_msc_flash.c
@@ -62,13 +62,13 @@ bool usb_msc_ejected(void) {
}
// The root FS is always at the end of the list.
-static fs_user_mount_t* get_vfs(int lun) {
+static fs_user_mount_t *get_vfs(int lun) {
// TODO(tannewt): Return the mount which matches the lun where 0 is the end
// and is counted in reverse.
if (lun > 0) {
return NULL;
}
- mp_vfs_mount_t* current_mount = MP_STATE_VM(vfs_mount_table);
+ mp_vfs_mount_t *current_mount = MP_STATE_VM(vfs_mount_table);
if (current_mount == NULL) {
return NULL;
}
@@ -81,40 +81,40 @@ static fs_user_mount_t* get_vfs(int lun) {
// Callback invoked when received an SCSI command not in built-in list below
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, TEST_UNIT_READY, START_STOP_UNIT, MODE_SENSE6, REQUEST_SENSE
// - READ10 and WRITE10 have their own callbacks
-int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, uint16_t bufsize) {
- const void* response = NULL;
+int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, uint16_t bufsize) {
+ const void *response = NULL;
int32_t resplen = 0;
- switch ( scsi_cmd[0] ) {
+ switch (scsi_cmd[0]) {
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
// Host is about to read/write etc ... better not to disconnect disk
resplen = 0;
- break;
+ break;
default:
- // Set Sense = Invalid Command Operation
- tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
+ // Set Sense = Invalid Command Operation
+ tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
- // negative means error -> tinyusb could stall and/or response with failed status
- resplen = -1;
- break;
+ // negative means error -> tinyusb could stall and/or response with failed status
+ resplen = -1;
+ break;
}
// return len must not larger than bufsize
- if ( resplen > bufsize ) {
+ if (resplen > bufsize) {
resplen = bufsize;
}
// copy response to stack's buffer if any
- if ( response && (resplen > 0) ) {
+ if (response && (resplen > 0)) {
memcpy(buffer, response, resplen);
}
return resplen;
}
-void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size) {
- fs_user_mount_t * vfs = get_vfs(lun);
+void tud_msc_capacity_cb(uint8_t lun, uint32_t *block_count, uint16_t *block_size) {
+ fs_user_mount_t *vfs = get_vfs(lun);
disk_ioctl(vfs, GET_SECTOR_COUNT, block_count);
disk_ioctl(vfs, GET_SECTOR_SIZE, block_size);
}
@@ -124,7 +124,7 @@ bool tud_msc_is_writable_cb(uint8_t lun) {
return false;
}
- fs_user_mount_t* vfs = get_vfs(lun);
+ fs_user_mount_t *vfs = get_vfs(lun);
if (vfs == NULL) {
return false;
}
@@ -136,13 +136,13 @@ bool tud_msc_is_writable_cb(uint8_t lun) {
// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
-int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
- (void) lun;
- (void) offset;
+int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize) {
+ (void)lun;
+ (void)offset;
const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE;
- fs_user_mount_t * vfs = get_vfs(lun);
+ fs_user_mount_t *vfs = get_vfs(lun);
disk_read(vfs, buffer, lba, block_count);
return block_count * MSC_FLASH_BLOCK_SIZE;
@@ -150,13 +150,13 @@ int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buf
// Callback invoked when received WRITE10 command.
// Process data in buffer to disk's storage and return number of written bytes
-int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
- (void) lun;
- (void) offset;
+int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize) {
+ (void)lun;
+ (void)offset;
const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE;
- fs_user_mount_t * vfs = get_vfs(lun);
+ fs_user_mount_t *vfs = get_vfs(lun);
disk_write(vfs, buffer, lba, block_count);
// Since by getting here we assume the mount is read-only to
// MicroPython let's update the cached FatFs sector if it's the one
@@ -166,11 +166,11 @@ int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
#else
// The compiler can optimize this away.
if (_MAX_SS == FILESYSTEM_BLOCK_SIZE) {
- #endif
+ #endif
if (lba == vfs->fatfs.winsect && lba > 0) {
memcpy(vfs->fatfs.win,
- buffer + MSC_FLASH_BLOCK_SIZE * (vfs->fatfs.winsect - lba),
- MSC_FLASH_BLOCK_SIZE);
+ buffer + MSC_FLASH_BLOCK_SIZE * (vfs->fatfs.winsect - lba),
+ MSC_FLASH_BLOCK_SIZE);
}
}
@@ -179,8 +179,8 @@ int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
// used to flush any pending cache.
-void tud_msc_write10_complete_cb (uint8_t lun) {
- (void) lun;
+void tud_msc_write10_complete_cb(uint8_t lun) {
+ (void)lun;
// This write is complete, start the autoreload clock.
autoreload_start();
@@ -189,10 +189,10 @@ void tud_msc_write10_complete_cb (uint8_t lun) {
// Invoked when received SCSI_CMD_INQUIRY
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
- (void) lun;
+ (void)lun;
- memcpy(vendor_id , CFG_TUD_MSC_VENDOR , strlen(CFG_TUD_MSC_VENDOR));
- memcpy(product_id , CFG_TUD_MSC_PRODUCT , strlen(CFG_TUD_MSC_PRODUCT));
+ memcpy(vendor_id, CFG_TUD_MSC_VENDOR, strlen(CFG_TUD_MSC_VENDOR));
+ memcpy(product_id, CFG_TUD_MSC_PRODUCT, strlen(CFG_TUD_MSC_PRODUCT));
memcpy(product_rev, CFG_TUD_MSC_PRODUCT_REV, strlen(CFG_TUD_MSC_PRODUCT_REV));
}
@@ -203,7 +203,7 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) {
return false;
}
- fs_user_mount_t* current_mount = get_vfs(lun);
+ fs_user_mount_t *current_mount = get_vfs(lun);
if (current_mount == NULL) {
return false;
}
@@ -223,7 +223,7 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
if (lun > 1) {
return false;
}
- fs_user_mount_t* current_mount = get_vfs(lun);
+ fs_user_mount_t *current_mount = get_vfs(lun);
if (current_mount == NULL) {
return false;
}
diff --git a/supervisor/spi_flash_api.h b/supervisor/spi_flash_api.h
index f59346e25..ed80b8207 100644
--- a/supervisor/spi_flash_api.h
+++ b/supervisor/spi_flash_api.h
@@ -33,17 +33,17 @@
#include "shared-bindings/busio/SPI.h"
-extern busio_spi_obj_t supervisor_flash_spi_bus; //Used to share SPI bus on some boards
+extern busio_spi_obj_t supervisor_flash_spi_bus; // Used to share SPI bus on some boards
// This API is implemented for both normal SPI peripherals and QSPI peripherals.
bool spi_flash_command(uint8_t command);
-bool spi_flash_read_command(uint8_t command, uint8_t* response, uint32_t length);
-bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t length);
+bool spi_flash_read_command(uint8_t command, uint8_t *response, uint32_t length);
+bool spi_flash_write_command(uint8_t command, uint8_t *data, uint32_t length);
bool spi_flash_sector_command(uint8_t command, uint32_t address);
-bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t data_length);
-bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t data_length);
+bool spi_flash_write_data(uint32_t address, uint8_t *data, uint32_t data_length);
+bool spi_flash_read_data(uint32_t address, uint8_t *data, uint32_t data_length);
void spi_flash_init(void);
-void spi_flash_init_device(const external_flash_device* device);
+void spi_flash_init_device(const external_flash_device *device);
#endif // MICROPY_INCLUDED_SUPERVISOR_SPI_FLASH_H
diff --git a/supervisor/stub/filesystem.c b/supervisor/stub/filesystem.c
index 1c4a3e12d..2b518f414 100644
--- a/supervisor/stub/filesystem.c
+++ b/supervisor/stub/filesystem.c
@@ -27,15 +27,15 @@
#include "supervisor/filesystem.h"
void filesystem_init(bool create_allowed, bool force_create) {
- (void) create_allowed;
- (void) force_create;
+ (void)create_allowed;
+ (void)force_create;
}
void filesystem_flush(void) {
}
bool filesystem_is_writable_by_python(fs_user_mount_t *vfs) {
- (void) vfs;
+ (void)vfs;
return true;
}
diff --git a/supervisor/stub/safe_mode.c b/supervisor/stub/safe_mode.c
index a70ac6b6d..b62cc05d7 100644
--- a/supervisor/stub/safe_mode.c
+++ b/supervisor/stub/safe_mode.c
@@ -33,10 +33,10 @@ safe_mode_t wait_for_safe_mode_reset(void) {
}
void reset_into_safe_mode(safe_mode_t reason) {
- (void) reason;
+ (void)reason;
abort();
}
void print_safe_mode_message(safe_mode_t reason) {
- (void) reason;
+ (void)reason;
}
diff --git a/supervisor/stub/serial.c b/supervisor/stub/serial.c
index 34b433e53..fc8bd221e 100644
--- a/supervisor/stub/serial.c
+++ b/supervisor/stub/serial.c
@@ -46,6 +46,6 @@ bool serial_bytes_available(void) {
return false;
}
-void serial_write(const char* text) {
- (void) text;
+void serial_write(const char *text) {
+ (void)text;
}
diff --git a/supervisor/stub/stack.c b/supervisor/stub/stack.c
index 9a9ecd32f..2abc19787 100644
--- a/supervisor/stub/stack.c
+++ b/supervisor/stub/stack.c
@@ -40,7 +40,7 @@ void stack_resize(void) {
}
void set_next_stack_size(uint32_t size) {
- (void) size;
+ (void)size;
}
uint32_t get_current_stack_size(void) {