Merge remote-tracking branch 'adafruit/master' into dac51
This commit is contained in:
commit
0fed65e7d2
|
@ -82,6 +82,7 @@ jobs:
|
|||
- "circuitplayground_bluefruit"
|
||||
- "circuitplayground_express"
|
||||
- "circuitplayground_express_crickit"
|
||||
- "circuitplayground_express_displayio"
|
||||
- "cp32-m4"
|
||||
- "datalore_ip_m4"
|
||||
- "datum_distance"
|
||||
|
@ -135,6 +136,7 @@ jobs:
|
|||
- "robohatmm1_m0"
|
||||
- "robohatmm1_m4"
|
||||
- "sam32"
|
||||
- "serpente"
|
||||
- "snekboard"
|
||||
- "sparkfun_lumidrive"
|
||||
- "sparkfun_nrf52840_mini"
|
||||
|
|
|
@ -78,7 +78,7 @@ If you'd like to use the term "CircuitPython" and Blinka for your product here i
|
|||
* Your product is supported by the primary
|
||||
`"adafruit/circuitpython" <https://github.com/adafruit/circuitpython>`_ repo. This way we can
|
||||
update any custom code as we update the CircuitPython internals.
|
||||
* Your product is listed on `circuitpython.org <https:/circuitpython.org>`__ (source
|
||||
* Your product is listed on `circuitpython.org <https://circuitpython.org>`__ (source
|
||||
`here <https://github.com/adafruit/circuitpython-org/>`_). This is to ensure that a user of your
|
||||
product can always download the latest version of CircuitPython from the standard place.
|
||||
* Your product has a user accessible USB plug which appears as a CIRCUITPY drive when plugged in.
|
||||
|
|
|
@ -511,7 +511,7 @@ msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù."
|
|||
|
||||
#: ports/nrf/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Device in use"
|
||||
msgstr ""
|
||||
msgstr "Zhèngzài shǐyòng de shèbèi"
|
||||
|
||||
#: shared-bindings/displayio/Display.c
|
||||
msgid "Display must have a 16 bit colorspace."
|
||||
|
@ -871,7 +871,7 @@ msgstr "Ānquán móshì wúxiào"
|
|||
|
||||
#: shared-bindings/audiomixer/Mixer.c
|
||||
msgid "Invalid voice"
|
||||
msgstr ""
|
||||
msgstr "Yǔyīn wúxiào"
|
||||
|
||||
#: shared-bindings/audiomixer/Mixer.c
|
||||
msgid "Invalid voice count"
|
||||
|
@ -2083,7 +2083,7 @@ msgstr "bù yǔnxǔ gāi lèixíng de chángdù cānshù"
|
|||
|
||||
#: shared-bindings/audiomixer/MixerVoice.c
|
||||
msgid "level must be between 0 and 1"
|
||||
msgstr ""
|
||||
msgstr "Level bìxū jiè yú 0 hé 1 zhī jiān"
|
||||
|
||||
#: py/objarray.c
|
||||
msgid "lhs and rhs should be compatible"
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "hal/include/hal_gpio.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/neopixel_write/__init__.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Check the status of the two buttons on CircuitPlayground Express. If both are
|
||||
// pressed, then boot into user safe mode.
|
||||
bool board_requests_safe_mode(void) {
|
||||
gpio_set_pin_function(PIN_PA14, GPIO_PIN_FUNCTION_OFF);
|
||||
gpio_set_pin_direction(PIN_PA14, GPIO_DIRECTION_IN);
|
||||
gpio_set_pin_pull_mode(PIN_PA14, GPIO_PULL_DOWN);
|
||||
|
||||
gpio_set_pin_function(PIN_PA28, GPIO_PIN_FUNCTION_OFF);
|
||||
gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_IN);
|
||||
gpio_set_pin_pull_mode(PIN_PA28, GPIO_PULL_DOWN);
|
||||
bool safe_mode = gpio_get_pin_level(PIN_PA14) &&
|
||||
gpio_get_pin_level(PIN_PA28);
|
||||
reset_pin_number(PIN_PA14);
|
||||
reset_pin_number(PIN_PA28);
|
||||
return safe_mode;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
uint8_t empty[30];
|
||||
memset(empty, 0, 30);
|
||||
digitalio_digitalinout_obj_t neopixel_pin;
|
||||
common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23);
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
|
||||
DRIVE_MODE_PUSH_PULL);
|
||||
common_hal_neopixel_write(&neopixel_pin, empty, 30);
|
||||
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express with displayio"
|
||||
#define MICROPY_HW_MCU_NAME "samd21g18"
|
||||
|
||||
#define MICROPY_HW_LED_STATUS (&pin_PA17)
|
||||
|
||||
// Don't allow touch on A0 (PA02), because it's connected to the speaker.
|
||||
#define PA02_NO_TOUCH (true)
|
||||
|
||||
// Salae reads 12mhz which is the limit even though we set it to the safer 8mhz.
|
||||
#define SPI_FLASH_BAUDRATE (8000000)
|
||||
|
||||
// On-board flash
|
||||
#define SPI_FLASH_MOSI_PIN &pin_PA20
|
||||
#define SPI_FLASH_MISO_PIN &pin_PA16
|
||||
#define SPI_FLASH_SCK_PIN &pin_PA21
|
||||
#define SPI_FLASH_CS_PIN &pin_PB22
|
||||
|
||||
// These are pins not to reset.
|
||||
#define MICROPY_PORT_A (0)
|
||||
#define MICROPY_PORT_B (0)
|
||||
#define MICROPY_PORT_C (0)
|
||||
|
||||
#define SPEAKER_ENABLE_PIN (&pin_PA30)
|
||||
|
||||
// If you change this, then make sure to update the linker scripts as well to
|
||||
// make sure you don't overwrite code.
|
||||
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
|
||||
|
||||
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
|
||||
|
||||
#define CALIBRATE_CRYSTALLESS 1
|
||||
|
||||
// Explanation of how a user got into safe mode.
|
||||
#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up"
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PA05)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_PA07)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_PA06)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_PB09)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_PB08)
|
||||
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA24 1
|
||||
#define IGNORE_PIN_PA25 1
|
|
@ -0,0 +1,31 @@
|
|||
LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
|
||||
USB_VID = 0x239A
|
||||
USB_PID = 0x8019
|
||||
USB_PRODUCT = "CircuitPlayground Express with displayio"
|
||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
||||
|
||||
CHIP_VARIANT = SAMD21G18A
|
||||
CHIP_FAMILY = samd21
|
||||
|
||||
SPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 2
|
||||
EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C"
|
||||
|
||||
# Turn off features and optimizations for Crickit build to make room for additional frozen libs.
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_BITBANGIO = 0
|
||||
CIRCUITPY_FREQUENCYIO = 0
|
||||
CIRCUITPY_I2CSLAVE = 0
|
||||
CIRCUITPY_PIXELBUF = 0
|
||||
CIRCUITPY_GAMEPAD = 0
|
||||
CIRCUITPY_RTC = 0
|
||||
|
||||
SUPEROPT_GC = 0
|
||||
CFLAGS_INLINE_LIMIT = 55
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
|
|
@ -0,0 +1,63 @@
|
|||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB03) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB03) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB03) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PA11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TEMPERATURE), MP_ROM_PTR(&pin_PA09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_PA28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_PA14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_PA15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PB23) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_REMOTEIN), MP_ROM_PTR(&pin_PA12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IR_RX), MP_ROM_PTR(&pin_PA12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_REMOTEOUT), MP_ROM_PTR(&pin_PA23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IR_TX), MP_ROM_PTR(&pin_PA23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IR_PROXIMITY), MP_ROM_PTR(&pin_PA04) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_PA10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_PA08) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_PA00) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_PA01) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_PA30) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
|
@ -6,9 +6,17 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TOUCH1), MP_ROM_PTR(&pin_PA06) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TOUCH2), MP_ROM_PTR(&pin_PB09) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TOUCH3), MP_ROM_PTR(&pin_PB08) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TOUCH4), MP_ROM_PTR(&pin_PA04) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PB04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA22) },
|
||||
|
|
|
@ -14,5 +14,3 @@ LONGINT_IMPL = MPZ
|
|||
|
||||
CIRCUITPY_AUDIOIO = 1
|
||||
CIRCUITPY_DISPLAYIO = 1
|
||||
# No touch on SAMD51 yet
|
||||
CIRCUITPY_TOUCHIO = 0
|
||||
|
|
|
@ -10,9 +10,13 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
|||
{ MP_OBJ_NEW_QSTR(MP_QSTR_HEADPHONE_RIGHT), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
|
||||
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB03) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_NOSE), MP_ROM_PTR(&pin_PB03) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB02) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_NOSE), MP_ROM_PTR(&pin_PB08) },
|
||||
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) },
|
||||
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA27) },
|
||||
|
||||
// I2C
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#define MICROPY_HW_BOARD_NAME "Serpente"
|
||||
#define MICROPY_HW_MCU_NAME "samd21e18"
|
||||
|
||||
#define MICROPY_HW_LED_STATUS (&pin_PA23)
|
||||
|
||||
#define SPI_FLASH_MOSI_PIN &pin_PA16
|
||||
#define SPI_FLASH_MISO_PIN &pin_PA18
|
||||
#define SPI_FLASH_SCK_PIN &pin_PA17
|
||||
#define SPI_FLASH_CS_PIN &pin_PA15
|
||||
|
||||
// These are pins not to reset.
|
||||
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01)
|
||||
#define MICROPY_PORT_B (0)
|
||||
#define MICROPY_PORT_C (0)
|
||||
|
||||
// If you change this, then make sure to update the linker scripts as well to
|
||||
// make sure you don't overwrite code.
|
||||
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
|
||||
|
||||
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PA05)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_PA04)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_PA06)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_PA09)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_PA08)
|
||||
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA24 1
|
||||
#define IGNORE_PIN_PA25 1
|
||||
|
||||
// Not connected
|
||||
#define IGNORE_PIN_PA13 1
|
||||
#define IGNORE_PIN_PA28 1
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
|
||||
USB_VID = 0x239A
|
||||
USB_PID = 0x8012
|
||||
USB_PRODUCT = "Serpente"
|
||||
USB_MANUFACTURER = "arturo182"
|
||||
|
||||
CHIP_VARIANT = SAMD21E18A
|
||||
CHIP_FAMILY = samd21
|
||||
|
||||
SPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 1
|
||||
EXTERNAL_FLASH_DEVICES = GD25Q32C
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_SMALL_BUILD = 1
|
|
@ -0,0 +1,40 @@
|
|||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_PA19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_PA22) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_PA23) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA08) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA04) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
||||
|
|
@ -67,8 +67,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
|||
const nrf_saadc_channel_config_t config = {
|
||||
.resistor_p = NRF_SAADC_RESISTOR_DISABLED,
|
||||
.resistor_n = NRF_SAADC_RESISTOR_DISABLED,
|
||||
.gain = NRF_SAADC_GAIN1_6,
|
||||
.reference = NRF_SAADC_REFERENCE_INTERNAL,
|
||||
.gain = NRF_SAADC_GAIN1_4,
|
||||
.reference = NRF_SAADC_REFERENCE_VDD4,
|
||||
.acq_time = NRF_SAADC_ACQTIME_3US,
|
||||
.mode = NRF_SAADC_MODE_SINGLE_ENDED,
|
||||
.burst = NRF_SAADC_BURST_DISABLED,
|
||||
|
@ -108,5 +108,6 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
|||
}
|
||||
|
||||
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
|
||||
// The nominal VCC voltage
|
||||
return 3.3f;
|
||||
}
|
||||
|
|
|
@ -145,6 +145,8 @@ CFLAGS += -DHSE_VALUE=8000000 -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BU
|
|||
SRC_STM32 = \
|
||||
boards/$(BOARD)/stm32f4xx_hal_msp.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c \
|
||||
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
|
||||
|
|
|
@ -80,11 +80,24 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_PC08), MP_ROM_PTR(&pin_PC08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) },
|
||||
//Names
|
||||
//ST LED names
|
||||
{ MP_ROM_QSTR(MP_QSTR_LD3), MP_ROM_PTR(&pin_PD13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LD4), MP_ROM_PTR(&pin_PD12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LD5), MP_ROM_PTR(&pin_PD14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LD6), MP_ROM_PTR(&pin_PD15) },
|
||||
//more useful LED names
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PD13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PD12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PD14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PD15) },
|
||||
//AnalogIO names
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) },
|
||||
//actual LED names
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_ORANGE), MP_ROM_PTR(&pin_PD13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PD12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PD14) },
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
|
||||
/* #define HAL_ADC_MODULE_ENABLED */
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_CAN_MODULE_ENABLED */
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
|
||||
/* #define HAL_ADC_MODULE_ENABLED */
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_CAN_MODULE_ENABLED */
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common-hal/analogio/AnalogIn.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_ll_gpio.h"
|
||||
#include "stm32f4xx_ll_adc.h"
|
||||
#include "stm32f4xx_ll_bus.h"
|
||||
|
||||
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
|
||||
// No ADC function on pin
|
||||
if (pin->adc_unit == 0x00) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
}
|
||||
// TODO: add ADC traits to structure?
|
||||
|
||||
// Note that ADC2 is always bundled pin-to-pin with ADC1 if it exists, and used only
|
||||
// for dual conversion. For this basic application it is never used.
|
||||
LL_GPIO_SetPinMode(pin_port(pin->port), (uint32_t)pin_mask(pin->number), LL_GPIO_MODE_ANALOG);
|
||||
if (pin->adc_unit & 0x01) {
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
||||
} else if (pin->adc_unit == 0x04) {
|
||||
#ifdef LL_APB2_GRP1_PERIPH_ADC3
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC3);
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid ADC Unit value"));
|
||||
}
|
||||
claim_pin(pin);
|
||||
self->pin = pin;
|
||||
}
|
||||
|
||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||
return self->pin == mp_const_none;
|
||||
}
|
||||
|
||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
||||
if (common_hal_analogio_analogin_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
reset_pin_number(self->pin->port,self->pin->number);
|
||||
self->pin = mp_const_none;
|
||||
}
|
||||
|
||||
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||
// Something else might have used the ADC in a different way,
|
||||
// so we completely re-initialize it.
|
||||
ADC_TypeDef * ADCx;
|
||||
|
||||
if(self->pin->adc_unit & 0x01) {
|
||||
ADCx = ADC1;
|
||||
} else if (self->pin->adc_unit == 0x04) {
|
||||
#ifdef ADC3
|
||||
ADCx = ADC3;
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid ADC Unit value"));
|
||||
}
|
||||
|
||||
LL_GPIO_SetPinMode(pin_port(self->pin->port), (uint32_t)pin_mask(self->pin->number), LL_GPIO_MODE_ANALOG);
|
||||
//LL_GPIO_PIN_0
|
||||
|
||||
//HAL Implementation
|
||||
ADC_HandleTypeDef AdcHandle;
|
||||
ADC_ChannelConfTypeDef sConfig;
|
||||
|
||||
AdcHandle.Instance = ADCx;
|
||||
AdcHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
|
||||
AdcHandle.Init.Resolution = ADC_RESOLUTION_12B;
|
||||
AdcHandle.Init.ScanConvMode = DISABLE;
|
||||
AdcHandle.Init.ContinuousConvMode = DISABLE;
|
||||
AdcHandle.Init.DiscontinuousConvMode = DISABLE;
|
||||
AdcHandle.Init.NbrOfDiscConversion = 0;
|
||||
AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
||||
AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
AdcHandle.Init.NbrOfConversion = 1;
|
||||
AdcHandle.Init.DMAContinuousRequests = DISABLE;
|
||||
AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||
HAL_ADC_Init(&AdcHandle);
|
||||
|
||||
sConfig.Channel = (uint32_t)self->pin->adc_channel; //ADC_CHANNEL_0 <-normal iteration, not mask
|
||||
sConfig.Rank = 1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_15CYCLES; //Taken from micropython
|
||||
HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
|
||||
|
||||
HAL_ADC_Start(&AdcHandle);
|
||||
HAL_ADC_PollForConversion(&AdcHandle,1);
|
||||
uint16_t value = (uint16_t)HAL_ADC_GetValue(&AdcHandle);
|
||||
HAL_ADC_Stop(&AdcHandle);
|
||||
|
||||
// // Shift the value to be 16 bit.
|
||||
return value << 4;
|
||||
}
|
||||
|
||||
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
|
||||
return 3.3f;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_ANALOGIO_ANALOGIN_H
|
||||
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_ANALOGIO_ANALOGIN_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
const mcu_pin_obj_t * pin;
|
||||
} analogio_analogin_obj_t;
|
||||
|
||||
static inline uint8_t stm32_adc_units(uint8_t adc_packed) {
|
||||
return adc_packed >> 5;
|
||||
}
|
||||
|
||||
static inline uint8_t stm32_adc_channel(uint8_t adc_packed) {
|
||||
return adc_packed & 0x1f;
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_ANALOGIO_ANALOGIN_H
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/analogio/AnalogOut.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
mp_raise_ValueError(translate("DAC not supported"));
|
||||
}
|
||||
|
||||
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
||||
return self->deinited;
|
||||
}
|
||||
|
||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||
|
||||
}
|
||||
|
||||
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
|
||||
uint16_t value) {
|
||||
}
|
||||
|
||||
void analogout_reset(void) {
|
||||
// audioout_reset also resets the DAC, and does a smooth ramp down to avoid clicks
|
||||
// if it was enabled, so do that instead if AudioOut is enabled.
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGOUT_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
uint8_t channel;
|
||||
bool deinited;
|
||||
} analogio_analogout_obj_t;
|
||||
|
||||
void analogout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGOUT_H
|
|
@ -0,0 +1 @@
|
|||
// No analogio module functions.
|
|
@ -28,6 +28,7 @@
|
|||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_ll_gpio.h"
|
||||
|
||||
|
@ -47,7 +48,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
|
|||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(pin_port(self->pin->number), &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
|
||||
|
||||
return DIGITALINOUT_OK;
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
|
|||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(pin_port(self->pin->number), &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
|
||||
|
||||
common_hal_digitalio_digitalinout_set_pull(self, pull);
|
||||
}
|
||||
|
@ -89,20 +90,20 @@ void common_hal_digitalio_digitalinout_switch_to_output(
|
|||
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
|
||||
digitalio_digitalinout_obj_t *self) {
|
||||
|
||||
return (LL_GPIO_GetPinMode(pin_port(self->pin->number), pin_mask(self->pin->number))
|
||||
return (LL_GPIO_GetPinMode(pin_port(self->pin->port), pin_mask(self->pin->number))
|
||||
== LL_GPIO_MODE_INPUT) ? DIRECTION_INPUT : DIRECTION_OUTPUT;
|
||||
}
|
||||
|
||||
void common_hal_digitalio_digitalinout_set_value(
|
||||
digitalio_digitalinout_obj_t *self, bool value) {
|
||||
HAL_GPIO_WritePin(pin_port(self->pin->number), pin_mask(self->pin->number), value);
|
||||
HAL_GPIO_WritePin(pin_port(self->pin->port), pin_mask(self->pin->number), value);
|
||||
}
|
||||
|
||||
bool common_hal_digitalio_digitalinout_get_value(
|
||||
digitalio_digitalinout_obj_t *self) {
|
||||
return (LL_GPIO_GetPinMode(pin_port(self->pin->number), pin_mask(self->pin->number)) == LL_GPIO_MODE_INPUT)
|
||||
? HAL_GPIO_ReadPin(pin_port(self->pin->number), pin_mask(self->pin->number))
|
||||
: LL_GPIO_IsOutputPinSet(pin_port(self->pin->number), pin_mask(self->pin->number));
|
||||
return (LL_GPIO_GetPinMode(pin_port(self->pin->port), pin_mask(self->pin->number)) == LL_GPIO_MODE_INPUT)
|
||||
? HAL_GPIO_ReadPin(pin_port(self->pin->port), pin_mask(self->pin->number))
|
||||
: LL_GPIO_IsOutputPinSet(pin_port(self->pin->port), pin_mask(self->pin->number));
|
||||
}
|
||||
|
||||
void common_hal_digitalio_digitalinout_set_drive_mode(
|
||||
|
@ -114,13 +115,13 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
|
|||
GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP);
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(pin_port(self->pin->number), &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
|
||||
digitalio_digitalinout_obj_t *self) {
|
||||
|
||||
return LL_GPIO_GetPinOutputType(pin_port(self->pin->number), pin_mask(self->pin->number))
|
||||
return LL_GPIO_GetPinOutputType(pin_port(self->pin->port), pin_mask(self->pin->number))
|
||||
== LL_GPIO_OUTPUT_OPENDRAIN ? DRIVE_MODE_OPEN_DRAIN : DRIVE_MODE_PUSH_PULL;
|
||||
}
|
||||
|
||||
|
@ -129,13 +130,13 @@ void common_hal_digitalio_digitalinout_set_pull(
|
|||
|
||||
switch (pull) {
|
||||
case PULL_UP:
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->number), pin_mask(self->pin->number),LL_GPIO_PULL_UP);
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->port), pin_mask(self->pin->number),LL_GPIO_PULL_UP);
|
||||
break;
|
||||
case PULL_DOWN:
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->number), pin_mask(self->pin->number),LL_GPIO_PULL_DOWN);
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->port), pin_mask(self->pin->number),LL_GPIO_PULL_DOWN);
|
||||
break;
|
||||
case PULL_NONE:
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->number), pin_mask(self->pin->number),LL_GPIO_PULL_NO);
|
||||
LL_GPIO_SetPinPull(pin_port(self->pin->port), pin_mask(self->pin->number),LL_GPIO_PULL_NO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -146,7 +147,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
|
|||
digitalio_digitalinout_obj_t *self) {
|
||||
|
||||
|
||||
switch (LL_GPIO_GetPinPull(pin_port(self->pin->number), pin_mask(self->pin->number))) {
|
||||
switch (LL_GPIO_GetPinPull(pin_port(self->pin->port), pin_mask(self->pin->number))) {
|
||||
case LL_GPIO_PULL_UP:
|
||||
return PULL_UP;
|
||||
case LL_GPIO_PULL_DOWN:
|
||||
|
|
|
@ -17,6 +17,7 @@ CIRCUITPY_MINIMAL_BUILD = 1
|
|||
|
||||
CIRCUITPY_BOARD = 1
|
||||
CIRCUITPY_DIGITALIO = 1
|
||||
CIRCUITPY_ANALOGIO = 1
|
||||
CIRCUITPY_MICROCONTROLLER = 1
|
||||
CIRCUITPY_BUSIO = 1
|
||||
CIRCUITPY_TIME = 1
|
||||
|
|
|
@ -44,9 +44,10 @@ typedef struct {
|
|||
uint8_t adc_channel:5;
|
||||
} mcu_pin_obj_t;
|
||||
|
||||
//Standard stm32 adc unit combinations
|
||||
#define ADC_1 1
|
||||
#define ADC_123 7
|
||||
#define ADC_12 3
|
||||
#define ADC_123 7
|
||||
#define ADC_3 4
|
||||
|
||||
//STM32 ADC pins can have a combination of 1, 2 or all 3 ADCs on a single pin,
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
void stm32f4_peripherals_gpio_init(void) {
|
||||
//Enable all GPIO for now
|
||||
|
@ -133,6 +134,20 @@ void stm32f4_peripherals_gpio_init(void) {
|
|||
stm32f4_peripherals_status_led(1,0);
|
||||
stm32f4_peripherals_status_led(2,0);
|
||||
stm32f4_peripherals_status_led(3,0);
|
||||
|
||||
//Never reset pins
|
||||
never_reset_pin_number(2,13); //PC13 anti tamp
|
||||
never_reset_pin_number(2,14); //PC14 OSC32_IN
|
||||
never_reset_pin_number(2,15); //PC15 OSC32_OUT
|
||||
never_reset_pin_number(0,13); //PA13 SWDIO
|
||||
never_reset_pin_number(0,14); //PA14 SWCLK
|
||||
never_reset_pin_number(0,15); //PA15 JTDI
|
||||
never_reset_pin_number(1,3); //PB3 JTDO
|
||||
never_reset_pin_number(1,4); //PB4 JTRST
|
||||
|
||||
// Port H is not included in GPIO port array
|
||||
// never_reset_pin_number(5,0); //PH0 JTDO
|
||||
// never_reset_pin_number(5,1); //PH1 JTRST
|
||||
}
|
||||
|
||||
//LEDs are inverted on F411 DISCO
|
||||
|
|
|
@ -94,9 +94,9 @@ const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC);
|
|||
const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); //SWDIO
|
||||
const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); //SWCLK
|
||||
const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); //JTDI
|
||||
|
||||
const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC);
|
||||
const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC);
|
||||
|
|
|
@ -179,6 +179,7 @@
|
|||
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
void stm32f4_peripherals_gpio_init(void) {
|
||||
//Enable all GPIO for now
|
||||
|
@ -207,6 +208,20 @@ void stm32f4_peripherals_gpio_init(void) {
|
|||
stm32f4_peripherals_status_led(1,0);
|
||||
stm32f4_peripherals_status_led(2,0);
|
||||
stm32f4_peripherals_status_led(3,0);
|
||||
|
||||
//Never reset pins
|
||||
never_reset_pin_number(2,13); //PC13 anti tamp
|
||||
never_reset_pin_number(2,14); //PC14 OSC32_IN
|
||||
never_reset_pin_number(2,15); //PC15 OSC32_OUT
|
||||
never_reset_pin_number(0,13); //PA13 SWDIO
|
||||
never_reset_pin_number(0,14); //PA14 SWCLK
|
||||
never_reset_pin_number(0,15); //PA15 JTDI
|
||||
never_reset_pin_number(1,3); //PB3 JTDO
|
||||
never_reset_pin_number(1,4); //PB4 JTRST
|
||||
|
||||
// Port H is not included in GPIO port array
|
||||
// never_reset_pin_number(5,0); //PH0 JTDO
|
||||
// never_reset_pin_number(5,1); //PH1 JTRST
|
||||
}
|
||||
|
||||
//LEDs are inverted on F411 DISCO
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "boards/board.h"
|
||||
#include "tick.h"
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "stm32f4/clocks.h"
|
||||
#include "stm32f4/gpio.h"
|
||||
|
||||
|
@ -48,7 +50,7 @@ safe_mode_t port_init(void) {
|
|||
}
|
||||
|
||||
void reset_port(void) {
|
||||
|
||||
reset_all_pins();
|
||||
}
|
||||
|
||||
void reset_to_bootloader(void) {
|
||||
|
@ -56,7 +58,7 @@ void reset_to_bootloader(void) {
|
|||
}
|
||||
|
||||
void reset_cpu(void) {
|
||||
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
extern uint32_t _ebss;
|
||||
|
@ -70,5 +72,8 @@ uint32_t port_get_saved_word(void) {
|
|||
}
|
||||
|
||||
void HardFault_Handler(void) {
|
||||
while(1) {}
|
||||
reset_into_safe_mode(HARD_CRASH);
|
||||
while (true) {
|
||||
asm("nop;");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "lib/mp-readline/readline.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
void init_usb_hardware(void) {
|
||||
//TODO: if future chips overload this with options, move to peripherals management.
|
||||
|
||||
|
@ -50,12 +52,15 @@ void init_usb_hardware(void) {
|
|||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
never_reset_pin_number(0, 11);
|
||||
never_reset_pin_number(0, 12);
|
||||
|
||||
/* Configure VBUS Pin */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
never_reset_pin_number(0, 9);
|
||||
|
||||
/* This for ID line debug */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||
|
@ -64,6 +69,7 @@ void init_usb_hardware(void) {
|
|||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
never_reset_pin_number(0, 10);
|
||||
|
||||
#ifdef STM32F412Zx
|
||||
/* Configure POWER_SWITCH IO pin (F412 ONLY)*/
|
||||
|
@ -71,6 +77,7 @@ void init_usb_hardware(void) {
|
|||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
||||
never_reset_pin_number(0, 8);
|
||||
#endif
|
||||
|
||||
/* Peripheral clock enable */
|
||||
|
|
|
@ -54,6 +54,11 @@ void SysTick_Handler(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
uint32_t HAL_GetTick(void) //override ST HAL
|
||||
{
|
||||
return (uint32_t)ticks_ms;
|
||||
}
|
||||
|
||||
void tick_init() {
|
||||
uint32_t ticks_per_ms = SystemCoreClock/ 1000;
|
||||
SysTick_Config(ticks_per_ms); // interrupt is enabled
|
||||
|
|
Loading…
Reference in New Issue