Browse Source
Quail (https://www.mikroe.com/quail, PID: MIKROE-1793) is based on an STM32F427VI CPU, featuring 2048 kB of Flash memory and 192 kB of RAM. An on-board Cypress S25FL164K adds 8 MB of SPI Flash. Quail has 4 mikroBUS(TM) sockets for Mikroe click(TM) board connectivity, along with 24 screw terminals for connecting additional electronics and two USB ports (one for programming, the other for external mass storage). 4 UARTs, 2 SPIs and 1 I2C bus are available for communication. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>pull/7934/head
Lorenzo Cappelletti
3 years ago
committed by
Damien George
9 changed files with 345 additions and 1 deletions
@ -0,0 +1,28 @@ |
|||||
|
#include "py/obj.h" |
||||
|
#include "storage.h" |
||||
|
#include "spi.h" |
||||
|
|
||||
|
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE |
||||
|
|
||||
|
STATIC const spi_proto_cfg_t spi_bus = { |
||||
|
.spi = &spi_obj[2], // SPI3 hardware peripheral
|
||||
|
.baudrate = 25000000, |
||||
|
.polarity = 0, |
||||
|
.phase = 0, |
||||
|
.bits = 8, |
||||
|
.firstbit = SPI_FIRSTBIT_MSB, |
||||
|
}; |
||||
|
|
||||
|
STATIC mp_spiflash_cache_t spi_bdev_cache; |
||||
|
|
||||
|
const mp_spiflash_config_t spiflash_config = { |
||||
|
.bus_kind = MP_SPIFLASH_BUS_SPI, |
||||
|
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS, |
||||
|
.bus.u_spi.data = (void *)&spi_bus, |
||||
|
.bus.u_spi.proto = &spi_proto, |
||||
|
.cache = &spi_bdev_cache, |
||||
|
}; |
||||
|
|
||||
|
spi_bdev_t spi_bdev; |
||||
|
|
||||
|
#endif |
@ -0,0 +1,18 @@ |
|||||
|
{ |
||||
|
"deploy": [ |
||||
|
"../MIKROE_QUAIL/deploy.md" |
||||
|
], |
||||
|
"docs": "", |
||||
|
"features": [ |
||||
|
"mikroBUS" |
||||
|
], |
||||
|
"id": "MIKROE-QUAIL", |
||||
|
"images": [ |
||||
|
"quail_top.jpg" |
||||
|
], |
||||
|
"mcu": "stm32f4", |
||||
|
"product": "MikroE Quail", |
||||
|
"thumbnail": "", |
||||
|
"url": "https://www.mikroe.com/quail", |
||||
|
"vendor": "MikroElektronika" |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
### Quail via DFU |
||||
|
|
||||
|
Quail can be programmed via USB with the ST DFU bootloader, using |
||||
|
e.g. [dfu-util](http://dfu-util.sourceforge.net/) or |
||||
|
[pydfu.py](https://github.com/micropython/micropython/blob/master/tools/pydfu.py). |
||||
|
|
||||
|
To enter the bootloader press and release the Reset button while holding the |
||||
|
Boot button. Alternatively, you can use `machine.bootloader()` from the |
||||
|
MicroPython REPL. |
||||
|
|
||||
|
```bash |
||||
|
dfu-util --alt 0 -D firmware.dfu |
||||
|
``` |
@ -0,0 +1,109 @@ |
|||||
|
#define MICROPY_HW_BOARD_NAME "MikroE Quail" |
||||
|
#define MICROPY_HW_MCU_NAME "STM32F427VI" |
||||
|
|
||||
|
// 1 = use STM32 internal flash (1 MByte)
|
||||
|
// 0 = use onboard external SPI flash (8 MByte)
|
||||
|
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0) |
||||
|
|
||||
|
#define MICROPY_HW_ENABLE_RNG (1) |
||||
|
#define MICROPY_HW_ENABLE_RTC (1) |
||||
|
#define MICROPY_HW_ENABLE_USB (1) |
||||
|
#define MICROPY_HW_HAS_FLASH (1) |
||||
|
|
||||
|
// HSE is 12MHz
|
||||
|
#define MICROPY_HW_CLK_PLLM (6) |
||||
|
#define MICROPY_HW_CLK_PLLN (336) |
||||
|
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV4) |
||||
|
#define MICROPY_HW_CLK_PLLQ (14) |
||||
|
#define MICROPY_HW_CLK_LAST_FREQ (1) |
||||
|
|
||||
|
// The board has no crystal for the RTC
|
||||
|
#define MICROPY_HW_RTC_USE_LSE (0) |
||||
|
#define MICROPY_HW_RTC_USE_US (0) |
||||
|
#define MICROPY_HW_RTC_USE_CALOUT (0) // turn on/off PC13 512Hz output
|
||||
|
|
||||
|
// UART config
|
||||
|
// mikroBUS slot 1
|
||||
|
#define MICROPY_HW_UART3_NAME "SLOT1" |
||||
|
#define MICROPY_HW_UART3_TX (pin_D8) |
||||
|
#define MICROPY_HW_UART3_RX (pin_D9) |
||||
|
// mikroBUS slot 2
|
||||
|
#define MICROPY_HW_UART2_NAME "SLOT2" |
||||
|
#define MICROPY_HW_UART2_TX (pin_D5) |
||||
|
#define MICROPY_HW_UART2_RX (pin_D6) |
||||
|
// mikroBUS slot 3
|
||||
|
#define MICROPY_HW_UART6_NAME "SLOT3" |
||||
|
#define MICROPY_HW_UART6_TX (pin_C6) |
||||
|
#define MICROPY_HW_UART6_RX (pin_C7) |
||||
|
// mikroBUS slot 4
|
||||
|
#define MICROPY_HW_UART1_NAME "SLOT4" |
||||
|
#define MICROPY_HW_UART1_TX (pin_A9) |
||||
|
#define MICROPY_HW_UART1_RX (pin_A10) |
||||
|
|
||||
|
// I2C buses
|
||||
|
// mikroBUS slot 1, 2, 3, 4, and header
|
||||
|
#define MICROPY_HW_I2C1_NAME "SLOT1234H" |
||||
|
#define MICROPY_HW_I2C1_SCL (pin_B6) |
||||
|
#define MICROPY_HW_I2C1_SDA (pin_B7) |
||||
|
|
||||
|
// SPI buses
|
||||
|
// mikroBUS slot 1, 2, and header
|
||||
|
#define MICROPY_HW_SPI1_NAME "SLOT12H" |
||||
|
#define MICROPY_HW_SPI1_SCK (pin_B3) |
||||
|
#define MICROPY_HW_SPI1_MISO (pin_B4) |
||||
|
#define MICROPY_HW_SPI1_MOSI (pin_B5) |
||||
|
// mikroBUS slot 3, 4, and FLASH
|
||||
|
#define MICROPY_HW_SPI3_NAME "SLOT34F" |
||||
|
#define MICROPY_HW_SPI3_SCK (pin_C10) |
||||
|
#define MICROPY_HW_SPI3_MISO (pin_C11) |
||||
|
#define MICROPY_HW_SPI3_MOSI (pin_C12) |
||||
|
|
||||
|
// LEDs
|
||||
|
#define MICROPY_HW_LED1 (pin_E15) // orange
|
||||
|
#define MICROPY_HW_LED2 (pin_E10) // green
|
||||
|
#define MICROPY_HW_LED3 (pin_C3) // red
|
||||
|
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin)) |
||||
|
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin)) |
||||
|
|
||||
|
// USB config
|
||||
|
#define MICROPY_HW_USB_FS (1) |
||||
|
|
||||
|
// External SPI Flash config (Cypress S25FL164K)
|
||||
|
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE |
||||
|
|
||||
|
#define MICROPY_HW_SPIFLASH_SIZE_BITS (64 * 1024 * 1024) // 64 Mbit (8 MByte)
|
||||
|
|
||||
|
#define MICROPY_HW_SPIFLASH_CS (pin_A13) |
||||
|
#define MICROPY_HW_SPIFLASH_SCK (MICROPY_HW_SPI3_SCK) |
||||
|
#define MICROPY_HW_SPIFLASH_MISO (MICROPY_HW_SPI3_MISO) |
||||
|
#define MICROPY_HW_SPIFLASH_MOSI (MICROPY_HW_SPI3_MOSI) |
||||
|
|
||||
|
extern const struct _mp_spiflash_config_t spiflash_config; |
||||
|
extern struct _spi_bdev_t spi_bdev; |
||||
|
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1) |
||||
|
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \ |
||||
|
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \ |
||||
|
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \ |
||||
|
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \ |
||||
|
) |
||||
|
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n)) |
||||
|
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n)) |
||||
|
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
|
||||
|
|
||||
|
#endif // !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
|
||||
|
|
||||
|
// Bootloader configuration (only needed if Mboot is used)
|
||||
|
#define MBOOT_I2C_PERIPH_ID 1 |
||||
|
#define MBOOT_I2C_SCL (pin_B6) |
||||
|
#define MBOOT_I2C_SDA (pin_B7) |
||||
|
#define MBOOT_I2C_ALTFUNC (4) |
||||
|
#define MBOOT_FSLOAD (1) |
||||
|
#define MBOOT_VFS_FAT (1) |
||||
|
|
||||
|
#define MBOOT_SPIFLASH_ADDR (0x80000000) |
||||
|
#define MBOOT_SPIFLASH_BYTE_SIZE (8 * 1024 * 1024) |
||||
|
#define MBOOT_SPIFLASH_LAYOUT "/0x80000000/512*8Kg" |
||||
|
#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE \ |
||||
|
(8 / 4) // 8k page, 4k erase block
|
||||
|
#define MBOOT_SPIFLASH_CONFIG (&spiflash_config) |
||||
|
#define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash) |
@ -0,0 +1,10 @@ |
|||||
|
MCU_SERIES = f4 |
||||
|
CMSIS_MCU = STM32F427xx |
||||
|
LD_FILES = boards/stm32f427xi.ld boards/common_ifs.ld |
||||
|
TEXT0_ADDR = 0x08000000 |
||||
|
TEXT1_ADDR = 0x08020000 |
||||
|
|
||||
|
# According to the datasheet, page 75, table 12, the alternate functions
|
||||
|
# of STM32F427xx and STM32F429xx are exactly the same.
|
||||
|
# See https://www.st.com/resource/en/datasheet/stm32f427vi.pdf.
|
||||
|
AF_FILE = boards/stm32f429_af.csv |
Can't render this file because it has a wrong number of fields in line 3.
|
@ -0,0 +1,18 @@ |
|||||
|
/* This file is part of the MicroPython project, http://micropython.org/
|
||||
|
* The MIT License (MIT) |
||||
|
* Copyright (c) 2021 Lorenzo Cappelletti |
||||
|
*/ |
||||
|
#ifndef MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H |
||||
|
#define MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H |
||||
|
|
||||
|
#include "boards/stm32f4xx_hal_conf_base.h" |
||||
|
|
||||
|
// Oscillator values in Hz
|
||||
|
#define HSE_VALUE (12000000) |
||||
|
#define EXTERNAL_CLOCK_VALUE (12288000) |
||||
|
|
||||
|
// Oscillator timeouts in ms
|
||||
|
#define HSE_STARTUP_TIMEOUT (100) |
||||
|
#define LSE_STARTUP_TIMEOUT (0) |
||||
|
|
||||
|
#endif // MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H
|
@ -0,0 +1,28 @@ |
|||||
|
/* |
||||
|
GNU linker script for STM32F427xI |
||||
|
*/ |
||||
|
|
||||
|
/* Specify the memory areas */ |
||||
|
MEMORY |
||||
|
{ |
||||
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */ |
||||
|
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0, 16 KiB */ |
||||
|
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1-4: 3*16K+64K */ |
||||
|
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 5-11 are 128K */ |
||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K |
||||
|
} |
||||
|
|
||||
|
/* produce a link error if there is not this amount of RAM for these sections */ |
||||
|
_minimum_stack_size = 2K; |
||||
|
_minimum_heap_size = 16K; |
||||
|
|
||||
|
/* Define the stack. The stack is full descending so begins just above last byte |
||||
|
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */ |
||||
|
_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve; |
||||
|
_sstack = _estack - 16K; /* tunable */ |
||||
|
|
||||
|
/* RAM extents for the garbage collector */ |
||||
|
_ram_start = ORIGIN(RAM); |
||||
|
_ram_end = ORIGIN(RAM) + LENGTH(RAM); |
||||
|
_heap_start = _ebss; /* heap starts just after statically allocated memory */ |
||||
|
_heap_end = _sstack; |
Loading…
Reference in new issue