fixup examples based on default pin #define-s and also support them being undefined

This commit is contained in:
graham sanderson
2021-02-28 09:00:36 -06:00
committed by Graham Sanderson
parent 9c7e31b8e7
commit 82b6dc0576
10 changed files with 101 additions and 43 deletions

View File

@@ -26,12 +26,20 @@
#include "pico/bootrom.h"
int main() {
flash_range_erase(0, PICO_FLASH_SIZE_BYTES);
uint flash_size_bytes;
#ifndef PICO_FLASH_SIZE_BYTES
#warning PICO_FLASH_SIZE_BYTES not set, assuming 16M
flash_size_bytes = 16 * 1024 * 1024;
#else
flash_size_bytes = PICO_FLASH_SIZE_BYTES;
#endif
flash_range_erase(0, flash_size_bytes);
// Leave an eyecatcher pattern in the first page of flash so picotool can
// more easily check the size:
static const uint8_t eyecatcher[FLASH_PAGE_SIZE] = "NUKE";
flash_range_program(0, eyecatcher, FLASH_PAGE_SIZE);
#ifdef PICO_DEFAULT_LED_PIN
// Flash LED for success
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
@@ -41,6 +49,7 @@ int main() {
gpio_put(PICO_DEFAULT_LED_PIN, 0);
sleep_ms(100);
}
#endif
// Pop back up as an MSD drive
reset_usb_boot(0, 0);