Merge remote-tracking branch 'adafruit/main' into dotenv
This commit is contained in:
commit
a6b60d2083
|
@ -289,3 +289,6 @@
|
|||
[submodule "frozen/pew-pewpew-lcd"]
|
||||
path = frozen/pew-pewpew-lcd
|
||||
url = https://github.com/pypewpew/pew-pewpew-lcd.git
|
||||
[submodule "ports/espressif/boards/mixgo_ce_udisk/cp_lib"]
|
||||
path = ports/espressif/boards/mixgo_ce_udisk/cp_lib
|
||||
url = https://github.com/dahanzimin/circuitpython_lib.git
|
||||
|
|
|
@ -57,9 +57,9 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self,
|
|||
self->value = mp_obj_new_bytes(initial_value_bufinfo->buf, initial_value_bufinfo->len);
|
||||
|
||||
const mp_int_t max_length_max = 512;
|
||||
if (max_length < 0 || max_length > max_length_max) {
|
||||
mp_raise_ValueError(translate("max_length must be <= 512"));
|
||||
}
|
||||
|
||||
mp_arg_validate_int_range(max_length, 0, max_length_max, MP_QSTR_max_length);
|
||||
|
||||
self->max_length = max_length;
|
||||
self->fixed_length = fixed_length;
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
|
||||
#define mp_obj_fat_vfs_t fs_user_mount_t
|
||||
|
||||
// Factoring this common call saves about 90 bytes.
|
||||
STATIC NORETURN void mp_raise_OSError_fresult(FRESULT res) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
}
|
||||
|
||||
STATIC mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) {
|
||||
fs_user_mount_t *vfs = vfs_in;
|
||||
FILINFO fno;
|
||||
|
@ -64,7 +69,7 @@ STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
// don't error out if no filesystem, to let mkfs()/mount() create one if wanted
|
||||
vfs->blockdev.flags |= MP_BLOCKDEV_FLAG_NO_FILESYSTEM;
|
||||
} else if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(vfs);
|
||||
|
@ -97,7 +102,7 @@ STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
|
|||
res = f_mkfs(&vfs->fatfs, FM_FAT32, 0, working_buf, sizeof(working_buf));
|
||||
}
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
|
@ -172,7 +177,7 @@ STATIC mp_obj_t fat_vfs_ilistdir_func(size_t n_args, const mp_obj_t *args) {
|
|||
iter->is_str = is_str_type;
|
||||
FRESULT res = f_opendir(&self->fatfs, &iter->dir, path);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(iter);
|
||||
|
@ -188,7 +193,7 @@ STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_in
|
|||
FRESULT res = f_stat(&self->fatfs, path, &fno);
|
||||
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
// check if path is a file or directory
|
||||
|
@ -196,7 +201,7 @@ STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_in
|
|||
res = f_unlink(&self->fatfs, path);
|
||||
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
return mp_const_none;
|
||||
} else {
|
||||
|
@ -226,7 +231,7 @@ STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_
|
|||
FILINFO fno;
|
||||
FRESULT res = f_stat(&self->fatfs, old_path, &fno);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
if ((fno.fattrib & AM_DIR) != 0 &&
|
||||
strlen(new_path) > strlen(old_path) &&
|
||||
|
@ -245,7 +250,7 @@ STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_
|
|||
if (res == FR_OK) {
|
||||
return mp_const_none;
|
||||
} else {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -259,7 +264,7 @@ STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) {
|
|||
if (res == FR_OK) {
|
||||
return mp_const_none;
|
||||
} else {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir);
|
||||
|
@ -273,7 +278,7 @@ STATIC mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
FRESULT res = f_chdir(&self->fatfs, path);
|
||||
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
|
@ -286,7 +291,7 @@ STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) {
|
|||
char buf[MICROPY_ALLOC_PATH_MAX + 1];
|
||||
FRESULT res = f_getcwd(&self->fatfs, buf, sizeof(buf));
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
return mp_obj_new_str(buf, strlen(buf));
|
||||
}
|
||||
|
@ -307,7 +312,7 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
} else {
|
||||
FRESULT res = f_stat(&self->fatfs, path, &fno);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +362,7 @@ STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
FATFS *fatfs = &self->fatfs;
|
||||
FRESULT res = f_getfree(fatfs, &nclst);
|
||||
if (FR_OK != res) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
|
||||
|
@ -395,7 +400,7 @@ STATIC mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs
|
|||
res = f_mkfs(&self->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf));
|
||||
}
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
self->blockdev.flags &= ~MP_BLOCKDEV_FLAG_NO_FILESYSTEM;
|
||||
|
||||
|
@ -416,7 +421,7 @@ STATIC mp_obj_t vfs_fat_getlabel(mp_obj_t self_in) {
|
|||
char working_buf[12];
|
||||
FRESULT res = f_getlabel(&self->fatfs, working_buf, NULL);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
return mp_obj_new_str(working_buf, strlen(working_buf));
|
||||
}
|
||||
|
@ -431,7 +436,7 @@ STATIC mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) {
|
|||
if (res == FR_WRITE_PROTECTED) {
|
||||
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Read-only filesystem"));
|
||||
}
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
|
|||
}
|
||||
|
||||
if (rwxa_count != 1 || plus_count > 1 || bt_count > 1 || bad_mode) {
|
||||
mp_raise_ValueError(translate("Invalid mode"));
|
||||
mp_arg_error_invalid(MP_QSTR_mode);
|
||||
}
|
||||
|
||||
assert(vfs != NULL);
|
||||
|
|
909
locale/ID.po
909
locale/ID.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
652
locale/cs.po
652
locale/cs.po
File diff suppressed because it is too large
Load Diff
1037
locale/de_DE.po
1037
locale/de_DE.po
File diff suppressed because it is too large
Load Diff
641
locale/el.po
641
locale/el.po
File diff suppressed because it is too large
Load Diff
1015
locale/en_GB.po
1015
locale/en_GB.po
File diff suppressed because it is too large
Load Diff
999
locale/es.po
999
locale/es.po
File diff suppressed because it is too large
Load Diff
807
locale/fil.po
807
locale/fil.po
File diff suppressed because it is too large
Load Diff
1012
locale/fr.po
1012
locale/fr.po
File diff suppressed because it is too large
Load Diff
641
locale/hi.po
641
locale/hi.po
File diff suppressed because it is too large
Load Diff
833
locale/it_IT.po
833
locale/it_IT.po
File diff suppressed because it is too large
Load Diff
908
locale/ja.po
908
locale/ja.po
File diff suppressed because it is too large
Load Diff
678
locale/ko.po
678
locale/ko.po
File diff suppressed because it is too large
Load Diff
947
locale/nl.po
947
locale/nl.po
File diff suppressed because it is too large
Load Diff
875
locale/pl.po
875
locale/pl.po
File diff suppressed because it is too large
Load Diff
1023
locale/pt_BR.po
1023
locale/pt_BR.po
File diff suppressed because it is too large
Load Diff
889
locale/ru.po
889
locale/ru.po
File diff suppressed because it is too large
Load Diff
1020
locale/sv.po
1020
locale/sv.po
File diff suppressed because it is too large
Load Diff
684
locale/tr.po
684
locale/tr.po
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
|
|||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_RAINBOWIO = 0
|
||||
|
|
|
@ -7,5 +7,5 @@ CHIP_VARIANT = SAMD51J19A
|
|||
CHIP_FAMILY = samd51
|
||||
|
||||
QSPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICES = GD25Q64C
|
||||
EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ"
|
||||
LONGINT_IMPL = MPZ
|
||||
|
|
|
@ -7,5 +7,5 @@ CHIP_VARIANT = SAMD51J19A
|
|||
CHIP_FAMILY = samd51
|
||||
|
||||
QSPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICES = GD25Q64C
|
||||
EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ"
|
||||
LONGINT_IMPL = MPZ
|
||||
|
|
|
@ -7,7 +7,7 @@ CHIP_VARIANT = SAMD51J19A
|
|||
CHIP_FAMILY = samd51
|
||||
|
||||
QSPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICES = GD25Q64C
|
||||
EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ"
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
CIRCUITPY_AESIO = 0
|
||||
|
|
|
@ -234,7 +234,7 @@ static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) {
|
|||
// raise ValueError here
|
||||
MP_FALLTHROUGH
|
||||
case PINALARM_ERR_NOEXTINT:
|
||||
mp_raise_RuntimeError(translate("No hardware support on pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
case PINALARM_ERR_NOCHANNEL:
|
||||
mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use"));
|
||||
default:
|
||||
|
@ -261,7 +261,7 @@ static void pinalarm_set_alarms_deep(size_t n_alarms, const mp_obj_t *alarms) {
|
|||
}
|
||||
}
|
||||
if (t->n < 0) {
|
||||
mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
// It is strange, but to my experiment, interrupt during sleep
|
||||
|
|
|
@ -100,7 +100,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_
|
|||
continue;
|
||||
}
|
||||
if (timealarm_set) {
|
||||
mp_raise_ValueError(translate("Only one alarm.time alarm can be set."));
|
||||
mp_raise_ValueError(translate("Only one alarm.time alarm can be set"));
|
||||
}
|
||||
timealarm = MP_OBJ_TO_PTR(alarms[i]);
|
||||
timealarm_set = true;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "samd/adc.h"
|
||||
#include "shared-bindings/analogio/AnalogIn.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "atmel_start_pins.h"
|
||||
|
@ -60,7 +61,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
|
|||
}
|
||||
if (adc_channel == 0xff) {
|
||||
// No ADC function on that pin
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
claim_pin(pin);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
|
|||
#endif
|
||||
|
||||
default:
|
||||
mp_raise_ValueError(translate("AnalogOut not supported on given pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,16 +151,16 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
|||
}
|
||||
#endif
|
||||
if (bc_clock_unit == 0xff) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_bit_clock);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_clock);
|
||||
}
|
||||
if (ws_clock_unit == 0xff) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_word_select);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_word_select);
|
||||
}
|
||||
if (bc_clock_unit != ws_clock_unit) {
|
||||
mp_raise_ValueError(translate("Bit clock and word select must share a clock unit"));
|
||||
}
|
||||
if (serializer == 0xff) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_data);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_data);
|
||||
}
|
||||
self->clock_unit = ws_clock_unit;
|
||||
self->serializer = serializer;
|
||||
|
@ -255,7 +255,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
|||
}
|
||||
uint8_t channel_count = audiosample_channel_count(sample);
|
||||
if (channel_count > 2) {
|
||||
mp_raise_ValueError(translate("Too many channels in sample."));
|
||||
mp_raise_ValueError(translate("Too many channels in sample"));
|
||||
}
|
||||
#ifdef SAMD21
|
||||
uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_TX) | I2S_SERCTRL_TXSAME_SAME | I2S_SERCTRL_EXTEND_MSBIT | I2S_SERCTRL_TXDEFAULT_ONE | I2S_SERCTRL_SLOTADJ_LEFT;
|
||||
|
|
|
@ -121,7 +121,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
|||
self->clock_unit = 1;
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_clock);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_clock);
|
||||
}
|
||||
|
||||
self->data_pin = data_pin; // PA07, PA19 -> SD0, PA08, PB16 -> SD1
|
||||
|
@ -152,7 +152,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
|||
self->serializer = 1;
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_data);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_data);
|
||||
}
|
||||
|
||||
if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) {
|
||||
|
|
|
@ -136,20 +136,21 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
|
|||
mp_raise_ValueError(translate("Right channel unsupported"));
|
||||
}
|
||||
if (left_channel != &pin_PA02) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
claim_pin(left_channel);
|
||||
#endif
|
||||
#ifdef SAM_D5X_E5X
|
||||
self->right_channel = NULL;
|
||||
if (left_channel != &pin_PA02 && left_channel != &pin_PA05) {
|
||||
mp_raise_ValueError(translate("Invalid pin for left channel"));
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_left_channel);
|
||||
}
|
||||
if (right_channel != NULL && right_channel != &pin_PA02 && right_channel != &pin_PA05) {
|
||||
mp_raise_ValueError(translate("Invalid pin for right channel"));
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_right_channel);
|
||||
}
|
||||
if (right_channel == left_channel) {
|
||||
mp_raise_ValueError(translate("Cannot output both channels on the same pin"));
|
||||
mp_raise_ValueError_varg(translate("%q and %q must be different"),
|
||||
MP_QSTR_left_channel, MP_QSTR_right_channel);
|
||||
}
|
||||
claim_pin(left_channel);
|
||||
if (right_channel != NULL) {
|
||||
|
@ -376,14 +377,13 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self,
|
|||
audio_dma_result result = AUDIO_DMA_OK;
|
||||
uint32_t sample_rate = audiosample_sample_rate(sample);
|
||||
#ifdef SAMD21
|
||||
uint32_t max_sample_rate = 350000;
|
||||
const uint32_t max_sample_rate = 350000;
|
||||
#endif
|
||||
#ifdef SAM_D5X_E5X
|
||||
uint32_t max_sample_rate = 1000000;
|
||||
const uint32_t max_sample_rate = 1000000;
|
||||
#endif
|
||||
if (sample_rate > max_sample_rate) {
|
||||
mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate);
|
||||
}
|
||||
mp_arg_validate_int_max(sample_rate, max_sample_rate, MP_QSTR_sample_rate);
|
||||
|
||||
#ifdef SAMD21
|
||||
result = audio_dma_setup_playback(&self->left_dma, sample, loop, true, 0,
|
||||
false /* output unsigned */,
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "samd/sercom.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "common-hal/busio/__init__.h"
|
||||
|
@ -76,7 +77,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
self->sda_pin = NO_PIN;
|
||||
Sercom *sercom = samd_i2c_get_sercom(scl, sda, &sercom_index, &sda_pinmux, &scl_pinmux);
|
||||
if (sercom == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
#if CIRCUITPY_REQUIRE_I2C_PULLUPS
|
||||
|
@ -122,15 +123,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
// The maximum frequency divisor gives a clock rate of around 48MHz/2/255
|
||||
// but set_baudrate does not diagnose this problem. (This is not the
|
||||
// exact cutoff, but no frequency well under 100kHz is available)
|
||||
if (frequency < 95000) {
|
||||
mp_raise_ValueError(translate("Unsupported baudrate"));
|
||||
}
|
||||
|
||||
if (i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE) {
|
||||
if (frequency < 95000 &&
|
||||
i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE) {
|
||||
reset_pin_number(sda->number);
|
||||
reset_pin_number(scl->number);
|
||||
common_hal_busio_i2c_deinit(self);
|
||||
mp_raise_ValueError(translate("Unsupported baudrate"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
|
||||
self->sda_pin = sda->number;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
|
@ -33,7 +34,6 @@
|
|||
|
||||
#include "supervisor/board.h"
|
||||
#include "common-hal/busio/__init__.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "hal/include/hal_gpio.h"
|
||||
#include "hal/include/hal_spi_m_sync.h"
|
||||
|
@ -133,7 +133,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||
}
|
||||
}
|
||||
if (sercom == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
// Set up SPI clocks on SERCOM.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
|
||||
#include "mpconfigport.h"
|
||||
|
@ -76,12 +77,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
self->tx_pin = NO_PIN;
|
||||
|
||||
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||
mp_raise_NotImplementedError(translate("RS485"));
|
||||
}
|
||||
|
||||
if (bits > 8) {
|
||||
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
||||
}
|
||||
mp_arg_validate_int_max(bits, 8, MP_QSTR_bits);
|
||||
|
||||
bool have_tx = tx != NULL;
|
||||
bool have_rx = rx != NULL;
|
||||
|
@ -145,7 +144,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
}
|
||||
if (sercom == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
if (!have_tx) {
|
||||
tx_pad = 0;
|
||||
|
@ -175,7 +174,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
self->buffer = (uint8_t *)gc_alloc(self->buffer_length * sizeof(uint8_t), false, true);
|
||||
if (self->buffer == NULL) {
|
||||
common_hal_busio_uart_deinit(self);
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t));
|
||||
m_malloc_fail(self->buffer_length * sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -184,7 +183,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
|
||||
if (usart_async_init(usart_desc_p, sercom, self->buffer, self->buffer_length, NULL) != ERR_NONE) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
mp_raise_RuntimeError(translate("UART init"));
|
||||
}
|
||||
|
||||
// usart_async_init() sets a number of defaults based on a prototypical SERCOM
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "peripheral_clk_config.h"
|
||||
#include "hpl_gclk_config.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/time/__init__.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
@ -282,11 +283,11 @@ static void frequencyin_samd51_stop_dpll(void) {
|
|||
void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* self, const mcu_pin_obj_t* pin, const uint16_t capture_period) {
|
||||
|
||||
if (!pin->has_extint) {
|
||||
mp_raise_RuntimeError(translate("No hardware support on pin"));
|
||||
}
|
||||
if ((capture_period == 0) || (capture_period > 500)) {
|
||||
mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
mp_arg_validate_int_range(capture_period, 0, 500, MP_QSTR_capture_period);
|
||||
|
||||
uint32_t mask = 1 << pin->extint_channel;
|
||||
if (eic_get_enable() == 1 &&
|
||||
#ifdef SAMD21
|
||||
|
@ -569,9 +570,7 @@ uint16_t common_hal_frequencyio_frequencyin_get_capture_period(frequencyio_frequ
|
|||
}
|
||||
|
||||
void common_hal_frequencyio_frequencyin_set_capture_period(frequencyio_frequencyin_obj_t *self, uint16_t capture_period) {
|
||||
if ((capture_period == 0) || (capture_period > 500)) {
|
||||
mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500"));
|
||||
}
|
||||
mp_arg_validate_int_range(capture_period, 1, 500, MP_QSTR_capture_period);
|
||||
|
||||
self->capture_period = capture_period;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "shared-bindings/i2cperipheral/I2CPeripheral.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "common-hal/busio/I2C.h"
|
||||
|
||||
#include "shared/runtime/interrupt_char.h"
|
||||
|
@ -42,7 +43,7 @@ void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_periphe
|
|||
uint32_t sda_pinmux, scl_pinmux;
|
||||
Sercom *sercom = samd_i2c_get_sercom(scl, sda, &sercom_index, &sda_pinmux, &scl_pinmux);
|
||||
if (sercom == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
self->sercom = sercom;
|
||||
|
||||
|
|
|
@ -63,16 +63,16 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
|||
}
|
||||
// The peripheral supports 8, 10, 12, or 14 data bits, but the code only supports 8 at present
|
||||
if (data_count != 8) {
|
||||
mp_raise_ValueError_varg(translate("Invalid data_count %d"), data_count);
|
||||
mp_arg_error_invalid(MP_QSTR_datacount);
|
||||
}
|
||||
if (vertical_sync && vertical_sync->number != PIN_PCC_DEN1) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_vsync);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_vsync);
|
||||
}
|
||||
if (horizontal_reference && horizontal_reference->number != PIN_PCC_DEN2) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_href);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_href);
|
||||
}
|
||||
if (data_clock->number != PIN_PCC_CLK) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_data_clock);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_data_clock);
|
||||
}
|
||||
// technically, 0 was validated as free already but check again
|
||||
for (int i = 0; i < data_count; i++) {
|
||||
|
|
|
@ -66,7 +66,7 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||
if (runmode == RUNMODE_BOOTLOADER) {
|
||||
if (!bootloader_available()) {
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present."));
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
|
||||
}
|
||||
// Pretend to be the first of the two reset presses needed to enter the
|
||||
// bootloader. That way one reset will end in the bootloader.
|
||||
|
|
|
@ -79,7 +79,7 @@ static void resume_interrupt(ps2io_ps2_obj_t *self) {
|
|||
disable_interrupt(self);
|
||||
|
||||
self->state = STATE_IDLE;
|
||||
gpio_set_pin_function(self->clk_pin, GPIO_PIN_FUNCTION_A);
|
||||
gpio_set_pin_function(self->clock_pin, GPIO_PIN_FUNCTION_A);
|
||||
uint32_t mask = 1 << self->channel;
|
||||
EIC->INTFLAG.reg = mask << EIC_INTFLAG_EXTINT_Pos;
|
||||
EIC->INTENSET.reg = mask << EIC_INTENSET_EXTINT_Pos;
|
||||
|
@ -90,14 +90,14 @@ static void resume_interrupt(ps2io_ps2_obj_t *self) {
|
|||
static void clk_hi(ps2io_ps2_obj_t *self) {
|
||||
// External pull-up
|
||||
// Must set pull after setting direction.
|
||||
gpio_set_pin_direction(self->clk_pin, GPIO_DIRECTION_IN);
|
||||
gpio_set_pin_pull_mode(self->clk_pin, GPIO_PULL_OFF);
|
||||
gpio_set_pin_direction(self->clock_pin, GPIO_DIRECTION_IN);
|
||||
gpio_set_pin_pull_mode(self->clock_pin, GPIO_PULL_OFF);
|
||||
}
|
||||
|
||||
static bool wait_clk_lo(ps2io_ps2_obj_t *self, uint32_t us) {
|
||||
clk_hi(self);
|
||||
common_hal_mcu_delay_us(1);
|
||||
while (gpio_get_pin_level(self->clk_pin) && us) {
|
||||
while (gpio_get_pin_level(self->clock_pin) && us) {
|
||||
--us;
|
||||
common_hal_mcu_delay_us(1);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ static bool wait_clk_lo(ps2io_ps2_obj_t *self, uint32_t us) {
|
|||
static bool wait_clk_hi(ps2io_ps2_obj_t *self, uint32_t us) {
|
||||
clk_hi(self);
|
||||
common_hal_mcu_delay_us(1);
|
||||
while (!gpio_get_pin_level(self->clk_pin) && us) {
|
||||
while (!gpio_get_pin_level(self->clock_pin) && us) {
|
||||
--us;
|
||||
common_hal_mcu_delay_us(1);
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ static bool wait_clk_hi(ps2io_ps2_obj_t *self, uint32_t us) {
|
|||
}
|
||||
|
||||
static void clk_lo(ps2io_ps2_obj_t *self) {
|
||||
gpio_set_pin_pull_mode(self->clk_pin, GPIO_PULL_OFF);
|
||||
gpio_set_pin_direction(self->clk_pin, GPIO_DIRECTION_OUT);
|
||||
gpio_set_pin_level(self->clk_pin, 0);
|
||||
gpio_set_pin_pull_mode(self->clock_pin, GPIO_PULL_OFF);
|
||||
gpio_set_pin_direction(self->clock_pin, GPIO_DIRECTION_OUT);
|
||||
gpio_set_pin_level(self->clock_pin, 0);
|
||||
}
|
||||
|
||||
static void data_hi(ps2io_ps2_obj_t *self) {
|
||||
|
@ -244,19 +244,19 @@ void ps2_interrupt_handler(uint8_t channel) {
|
|||
}
|
||||
|
||||
void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self,
|
||||
const mcu_pin_obj_t *data_pin, const mcu_pin_obj_t *clk_pin) {
|
||||
if (!clk_pin->has_extint) {
|
||||
mp_raise_RuntimeError(translate("No hardware support on clk pin"));
|
||||
const mcu_pin_obj_t *data_pin, const mcu_pin_obj_t *clock_pin) {
|
||||
if (!clock_pin->has_extint) {
|
||||
mp_arg_error_invalid(MP_QSTR_clock_pin);
|
||||
}
|
||||
if (eic_get_enable() && !eic_channel_free(clk_pin->extint_channel)) {
|
||||
if (eic_get_enable() && !eic_channel_free(clock_pin->extint_channel)) {
|
||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
||||
}
|
||||
|
||||
clk_hi(self);
|
||||
data_hi(self);
|
||||
|
||||
self->channel = clk_pin->extint_channel;
|
||||
self->clk_pin = clk_pin->number;
|
||||
self->channel = clock_pin->extint_channel;
|
||||
self->clock_pin = clock_pin->number;
|
||||
self->data_pin = data_pin->number;
|
||||
self->state = STATE_IDLE;
|
||||
self->bufcount = 0;
|
||||
|
@ -264,19 +264,19 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self,
|
|||
self->bufposw = 0;
|
||||
self->waiting_cmd_response = false;
|
||||
|
||||
set_eic_channel_data(clk_pin->extint_channel, (void *)self);
|
||||
set_eic_channel_data(clock_pin->extint_channel, (void *)self);
|
||||
|
||||
// Check to see if the EIC is enabled and start it up if its not.'
|
||||
if (eic_get_enable() == 0) {
|
||||
turn_on_external_interrupt_controller();
|
||||
}
|
||||
|
||||
gpio_set_pin_function(clk_pin->number, GPIO_PIN_FUNCTION_A);
|
||||
gpio_set_pin_function(clock_pin->number, GPIO_PIN_FUNCTION_A);
|
||||
gpio_set_pin_function(data_pin->number, GPIO_PIN_FUNCTION_A);
|
||||
|
||||
turn_on_cpu_interrupt(self->channel);
|
||||
|
||||
claim_pin(clk_pin);
|
||||
claim_pin(clock_pin);
|
||||
claim_pin(data_pin);
|
||||
|
||||
// Set config will enable the EIC.
|
||||
|
@ -284,7 +284,7 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self,
|
|||
}
|
||||
|
||||
bool common_hal_ps2io_ps2_deinited(ps2io_ps2_obj_t *self) {
|
||||
return self->clk_pin == NO_PIN;
|
||||
return self->clock_pin == NO_PIN;
|
||||
}
|
||||
|
||||
void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t *self) {
|
||||
|
@ -293,9 +293,9 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t *self) {
|
|||
}
|
||||
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
|
||||
turn_off_eic_channel(self->channel);
|
||||
reset_pin_number(self->clk_pin);
|
||||
reset_pin_number(self->clock_pin);
|
||||
reset_pin_number(self->data_pin);
|
||||
self->clk_pin = NO_PIN;
|
||||
self->clock_pin = NO_PIN;
|
||||
self->data_pin = NO_PIN;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
uint8_t channel;
|
||||
uint8_t clk_pin;
|
||||
uint8_t clock_pin;
|
||||
uint8_t data_pin;
|
||||
|
||||
uint8_t state;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "samd/pins.h"
|
||||
#include "samd/timers.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/pulseio/PulseIn.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
@ -152,7 +153,7 @@ void pulsein_reset() {
|
|||
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
||||
const mcu_pin_obj_t *pin, uint16_t maxlen, bool idle_state) {
|
||||
if (!pin->has_extint) {
|
||||
mp_raise_RuntimeError(translate("No hardware support on pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) {
|
||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
||||
|
@ -160,7 +161,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||
|
||||
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
|
||||
if (self->buffer == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
|
||||
m_malloc_fail(maxlen * sizeof(uint16_t));
|
||||
}
|
||||
self->channel = pin->extint_channel;
|
||||
self->pin = pin->number;
|
||||
|
@ -344,15 +345,15 @@ bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t *self) {
|
|||
return (EIC->INTENSET.reg & (mask << EIC_INTENSET_EXTINT_Pos)) == 0;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self,
|
||||
int16_t index) {
|
||||
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_t index) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
if (index < 0) {
|
||||
index += self->len;
|
||||
}
|
||||
if (index < 0 || index >= self->len) {
|
||||
common_hal_mcu_enable_interrupts();
|
||||
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
|
||||
// Can't use mp_arg_validate_index_range() here due to the critical section.
|
||||
mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index);
|
||||
}
|
||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||
common_hal_mcu_enable_interrupts();
|
||||
|
|
|
@ -377,7 +377,7 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self,
|
|||
uint32_t frequency) {
|
||||
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
|
||||
if (frequency == 0 || frequency > system_clock / 2) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
const pin_timer_t *t = self->timer;
|
||||
uint8_t resolution;
|
||||
|
|
|
@ -68,13 +68,7 @@ int common_hal_rtc_get_calibration(void) {
|
|||
}
|
||||
|
||||
void common_hal_rtc_set_calibration(int calibration) {
|
||||
if (calibration > 127 || calibration < -127) {
|
||||
#if CIRCUITPY_FULL_BUILD
|
||||
mp_raise_ValueError(translate("calibration value out of range +/-127"));
|
||||
#else
|
||||
mp_raise_ValueError(translate("calibration is out of range"));
|
||||
#endif
|
||||
}
|
||||
mp_arg_validate_int_range(calibration, -127, 127, MP_QSTR_calibration);
|
||||
|
||||
hri_rtcmode0_write_FREQCORR_SIGN_bit(RTC, calibration < 0 ? 0 : 1);
|
||||
hri_rtcmode0_write_FREQCORR_VALUE_bf(RTC, abs(calibration));
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
#include "py/mphal.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/touchio/TouchIn.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
@ -60,7 +61,7 @@ static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
|
|||
void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
if (!pin->has_touch) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
claim_pin(pin);
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
}
|
||||
}
|
||||
if (instance_index == NUM_I2C) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
i2c_in_use[instance_index] = true;
|
||||
self->index = instance_index;
|
||||
|
|
|
@ -104,7 +104,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||
break;
|
||||
}
|
||||
if (instance_index == NUM_SPI) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
self->clock = clock;
|
||||
|
|
|
@ -162,13 +162,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
mp_float_t timeout, uint16_t receiver_buffer_size, byte *receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
if (bits > 8) {
|
||||
mp_raise_ValueError(translate("Invalid word/bit length"));
|
||||
}
|
||||
|
||||
if (receiver_buffer_size == 0) {
|
||||
mp_raise_ValueError(translate("Invalid buffer size"));
|
||||
}
|
||||
mp_arg_validate_int_max(bits, 8, MP_QSTR_bits);
|
||||
mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size);
|
||||
|
||||
if ((rs485_dir != NULL) || (rs485_invert)) {
|
||||
mp_raise_NotImplementedError(translate("RS485 Not yet supported on this device"));
|
||||
|
@ -203,7 +198,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
break;
|
||||
}
|
||||
if (instance_index == NUM_UART) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
self->rx_pin = rx;
|
||||
|
@ -224,7 +219,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
// in the long-lived pool is not strictly necessary)
|
||||
// (This is a macro.)
|
||||
if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) {
|
||||
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer"));
|
||||
m_malloc_fail(receiver_buffer_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/analogio/AnalogIn.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
typedef struct {
|
||||
const char *devpath;
|
||||
|
@ -52,7 +53,7 @@ STATIC analogin_dev_t analogin_dev[] = {
|
|||
|
||||
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||
if (!pin->analog) {
|
||||
mp_raise_ValueError(translate("AnalogIn not supported on given pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
self->number = -1;
|
||||
|
@ -65,13 +66,13 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const
|
|||
}
|
||||
|
||||
if (self->number < 0) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
if (analogin_dev[self->number].fd < 0) {
|
||||
analogin_dev[self->number].fd = open(analogin_dev[self->number].devpath, O_RDONLY);
|
||||
if (analogin_dev[self->number].fd < 0) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "shared-bindings/analogio/AnalogOut.h"
|
||||
|
||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||
mp_raise_RuntimeError(translate("AnalogOut functionality not supported"));
|
||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut);
|
||||
}
|
||||
|
||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||
|
|
|
@ -32,15 +32,16 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/busio/I2C.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl,
|
||||
const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) {
|
||||
if (frequency != I2C_SPEED_STANDARD && frequency != I2C_SPEED_FAST) {
|
||||
mp_raise_ValueError(translate("Unsupported baudrate"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
|
||||
if (scl->number != PIN_I2C0_BCK || sda->number != PIN_I2C0_BDT) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
claim_pin(scl);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock,
|
||||
const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
@ -55,7 +56,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
|
|||
}
|
||||
|
||||
if (port < 0) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
claim_pin(clock);
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
typedef struct {
|
||||
const char *devpath;
|
||||
|
@ -65,20 +66,12 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
struct termios tio;
|
||||
|
||||
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||
mp_raise_NotImplementedError(translate("RS485"));
|
||||
}
|
||||
|
||||
if (bits != 8) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
}
|
||||
|
||||
if (parity != BUSIO_UART_PARITY_NONE) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
}
|
||||
|
||||
if (stop != 1) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
}
|
||||
mp_arg_validate_int(bits, 8, MP_QSTR_bits);
|
||||
mp_arg_validate_int(parity, BUSIO_UART_PARITY_NONE, MP_QSTR_parity);
|
||||
mp_arg_validate_int(stop, 1, MP_QSTR_stop);
|
||||
|
||||
self->number = -1;
|
||||
|
||||
|
@ -91,13 +84,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
|
||||
if (self->number < 0) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
if (busio_uart_dev[self->number].fd < 0) {
|
||||
busio_uart_dev[self->number].fd = open(busio_uart_dev[self->number].devpath, O_RDWR);
|
||||
if (busio_uart_dev[self->number].fd < 0) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
mp_raise_RuntimeError(translate("UART init"));
|
||||
}
|
||||
|
||||
// Wait to make sure the UART is ready
|
||||
|
|
|
@ -121,11 +121,11 @@ static void camera_start_preview() {
|
|||
void common_hal_camera_construct(camera_obj_t *self) {
|
||||
if (camera_dev.fd < 0) {
|
||||
if (video_initialize(camera_dev.devpath) < 0) {
|
||||
mp_raise_ValueError(translate("Could not initialize Camera"));
|
||||
mp_raise_RuntimeError(translate("Camera init"));
|
||||
}
|
||||
camera_dev.fd = open(camera_dev.devpath, 0);
|
||||
if (camera_dev.fd < 0) {
|
||||
mp_raise_ValueError(translate("Could not initialize Camera"));
|
||||
mp_raise_RuntimeError(translate("Camera init"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,11 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||
if (pin->analog) {
|
||||
mp_raise_ValueError(translate("DigitalInOut not supported on given pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
claim_pin(pin);
|
||||
|
|
|
@ -56,7 +56,7 @@ void common_hal_gnss_construct(gnss_obj_t *self, unsigned long selection) {
|
|||
if (gnss_dev.fd < 0) {
|
||||
gnss_dev.fd = open(gnss_dev.devpath, O_RDONLY);
|
||||
if (gnss_dev.fd < 0) {
|
||||
mp_raise_ValueError(translate("Could not initialize GNSS"));
|
||||
mp_raise_RuntimeError(translate("GNSS init"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||
|
||||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||
if (runmode == RUNMODE_BOOTLOADER) {
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present."));
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
|
||||
} else if (runmode == RUNMODE_SAFE_MODE) {
|
||||
safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
|||
const mcu_pin_obj_t *pin, uint16_t maxlen, bool idle_state) {
|
||||
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
|
||||
if (self->buffer == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
|
||||
m_malloc_fail(maxlen * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
self->pin = pin;
|
||||
|
@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
|
|||
}
|
||||
if (index < 0 || index >= self->len) {
|
||||
common_hal_mcu_enable_interrupts();
|
||||
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
|
||||
mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index);
|
||||
}
|
||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||
common_hal_mcu_enable_interrupts();
|
||||
|
|
|
@ -74,7 +74,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
|
|||
self->variable_frequency = variable_frequency;
|
||||
|
||||
if (ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info)) < 0) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
ioctl(pwmout_dev[self->number].fd, PWMIOC_START, 0);
|
||||
|
||||
|
@ -116,7 +116,7 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t fr
|
|||
self->info.frequency = frequency;
|
||||
|
||||
if (ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info)) < 0) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,5 +50,5 @@ int common_hal_rtc_get_calibration(void) {
|
|||
}
|
||||
|
||||
void common_hal_rtc_set_calibration(int calibration) {
|
||||
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
|
||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/sdioio/SDCard.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
|
@ -42,7 +43,7 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
|
|||
struct geometry geo;
|
||||
|
||||
if (clock->number != PIN_SDIO_CLK || command->number != PIN_SDIO_CMD) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
uint8_t data_pins_num = 0;
|
||||
|
@ -54,11 +55,11 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
|
|||
}
|
||||
|
||||
if (data_pins_num != DATA_PINS_NUM) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
if (open_blockdriver("/dev/mmcsd0", 0, &self->inode) < 0) {
|
||||
mp_raise_ValueError(translate("Could not initialize SDCard"));
|
||||
mp_raise_RuntimeError(translate("SDCard init"));
|
||||
}
|
||||
|
||||
self->inode->u.i_bops->geometry(self->inode, &geo);
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 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 "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "py/mpstate.h"
|
||||
|
||||
void board_init(void) {
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO43);
|
||||
common_hal_never_reset_pin(&pin_GPIO44);
|
||||
#endif /* DEBUG */
|
||||
|
||||
mp_import_stat_t stat_b = mp_import_stat("boot.py");
|
||||
if (stat_b != MP_IMPORT_STAT_FILE) {
|
||||
FATFS *fatfs = &((fs_user_mount_t *)MP_STATE_VM(vfs_mount_table)->obj)->fatfs;
|
||||
FIL fs;
|
||||
UINT char_written = 0;
|
||||
const byte buffer[] = "#Serial port upload mode\nimport storage\nstorage.remount(\"/\", False)\nstorage.disable_usb_drive()\n";
|
||||
// Create or modify existing boot.py file
|
||||
f_open(fatfs, &fs, "/boot.py", FA_WRITE | FA_CREATE_ALWAYS);
|
||||
f_write(&fs, buffer, sizeof(buffer) - 1, &char_written);
|
||||
f_close(&fs);
|
||||
// Delete code.Py, use main.py
|
||||
mp_import_stat_t stat_c = mp_import_stat("code.py");
|
||||
if (stat_c == MP_IMPORT_STAT_FILE) {
|
||||
f_unlink(fatfs,"/code.py");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 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.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "MixGo CE"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S2"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO45)
|
|
@ -0,0 +1,23 @@
|
|||
USB_VID = 0x303A
|
||||
USB_PID = 0x80FD
|
||||
USB_PRODUCT = "MixGo CE"
|
||||
USB_MANUFACTURER = "Espressif"
|
||||
|
||||
IDF_TARGET = esp32s2
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# The default queue depth of 16 overflows on release builds,
|
||||
# so increase it to 32.
|
||||
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE=dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ=40m
|
||||
CIRCUITPY_ESP_FLASH_SIZE=4MB
|
||||
|
||||
CIRCUITPY_MODULE=wroom
|
||||
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
FROZEN_MPY_DIRS += boards/mixgo_ce_udisk/cp_lib/mixgoce_lib
|
|
@ -0,0 +1,50 @@
|
|||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
|
||||
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO45) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,6 @@
|
|||
# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
|
||||
# end of LWIP
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 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 "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO43);
|
||||
common_hal_never_reset_pin(&pin_GPIO44);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 8b6cd888b264abaf8f9b1904b09b01313b273bb2
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 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.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "MixGo CE"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S2"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO45)
|
|
@ -0,0 +1,23 @@
|
|||
USB_VID = 0x303A
|
||||
USB_PID = 0x80FC
|
||||
USB_PRODUCT = "MixGo CE"
|
||||
USB_MANUFACTURER = "Espressif"
|
||||
|
||||
IDF_TARGET = esp32s2
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# The default queue depth of 16 overflows on release builds,
|
||||
# so increase it to 32.
|
||||
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE=dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ=40m
|
||||
CIRCUITPY_ESP_FLASH_SIZE=4MB
|
||||
|
||||
CIRCUITPY_MODULE=wroom
|
||||
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
FROZEN_MPY_DIRS += boards/$(BOARD)/cp_lib/mixgoce_lib
|
|
@ -0,0 +1,50 @@
|
|||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
|
||||
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO45) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,6 @@
|
|||
# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
|
||||
# end of LWIP
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "shared-bindings/alarm/touch/TouchAlarm.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "esp_sleep.h"
|
||||
#include "peripherals/touch.h"
|
||||
|
@ -36,7 +37,7 @@ static volatile bool woke_up = false;
|
|||
|
||||
void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||
if (pin->touch_channel == TOUCH_PAD_MAX) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
claim_pin(pin);
|
||||
self->pin = pin;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
if (pin->adc_index == 0 || pin->adc_channel == ADC_CHANNEL_MAX) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
common_hal_mcu_pin_claim(pin);
|
||||
self->pin = pin;
|
||||
|
@ -80,7 +80,7 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
|||
} else if (self->pin->adc_index == ADC_UNIT_2) {
|
||||
adc2_config_channel_atten((adc2_channel_t)self->pin->adc_channel, ATTENUATION);
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid Pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
// Automatically select calibration process depending on status of efuse
|
||||
|
|
|
@ -49,7 +49,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
|
|||
} else if (pin == &pin_GPIO18) {
|
||||
self->channel = DAC_CHANNEL_2;
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid DAC pin supplied"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
dac_output_enable(self->channel);
|
||||
#else
|
||||
|
|
|
@ -42,7 +42,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
//
|
||||
// 46 is also input-only so it'll never work.
|
||||
if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
#if CIRCUITPY_REQUIRE_I2C_PULLUPS
|
||||
|
@ -113,7 +113,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
if (err == ESP_FAIL) {
|
||||
mp_raise_OSError(MP_EIO);
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid argument"));
|
||||
mp_raise_RuntimeError(translate("init I2C"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "driver/spi_common_internal.h"
|
||||
|
||||
|
@ -101,7 +102,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||
if (result == ESP_ERR_NO_MEM) {
|
||||
mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
|
||||
} else if (result == ESP_ERR_INVALID_ARG) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
set_spi_config(self, 250000, 0, 0, 8);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
|
||||
#include "components/driver/include/driver/uart.h"
|
||||
|
@ -101,9 +102,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
mp_float_t timeout, uint16_t receiver_buffer_size, byte *receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
if (bits > 8) {
|
||||
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
||||
}
|
||||
mp_arg_validate_int_max(bits, 8, MP_QSTR_bytes);
|
||||
|
||||
bool have_tx = tx != NULL;
|
||||
bool have_rx = rx != NULL;
|
||||
|
@ -158,7 +157,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
// Install the driver before we change the settings.
|
||||
if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK ||
|
||||
uart_set_mode(self->uart_num, mode) != ESP_OK) {
|
||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||
mp_raise_RuntimeError(translate("UART init"));
|
||||
}
|
||||
// On the debug uart, enable pattern detection to look for CTRL+C
|
||||
#ifdef CIRCUITPY_DEBUG_UART_RX
|
||||
|
@ -265,7 +264,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
rts_num = rs485_dir->number;
|
||||
}
|
||||
if (uart_set_pin(self->uart_num, tx_num, rx_num, rts_num, cts_num) != ESP_OK) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +375,7 @@ uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
|
|||
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
|
||||
if (baudrate > UART_BITRATE_MAX ||
|
||||
uart_set_baudrate(self->uart_num, baudrate) != ESP_OK) {
|
||||
mp_raise_ValueError(translate("Unsupported baudrate"));
|
||||
mp_arg_error_invalid(MP_QSTR_baudrate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t *
|
|||
if (result == ESP_ERR_NO_MEM) {
|
||||
mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
|
||||
} else if (result == ESP_ERR_INVALID_ARG) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
} else if (result != ESP_OK) {
|
||||
mp_raise_OSError_msg_varg(translate("twai_driver_install returned esp-idf error #%d"), (int)result);
|
||||
}
|
||||
|
|
|
@ -130,9 +130,7 @@ static void init_timer(frequencyio_frequencyin_obj_t *self) {
|
|||
|
||||
void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t *self,
|
||||
const mcu_pin_obj_t *pin, const uint16_t capture_period) {
|
||||
if ((capture_period == 0) || (capture_period > 500)) {
|
||||
mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500"));
|
||||
}
|
||||
mp_arg_validate_int_range(capture_period, 1, 500, MP_QSTR_capture_period);
|
||||
|
||||
self->pin = pin->number;
|
||||
self->handle = NULL;
|
||||
|
@ -188,9 +186,8 @@ uint16_t common_hal_frequencyio_frequencyin_get_capture_period(frequencyio_frequ
|
|||
}
|
||||
|
||||
void common_hal_frequencyio_frequencyin_set_capture_period(frequencyio_frequencyin_obj_t *self, uint16_t capture_period) {
|
||||
if ((capture_period == 0) || (capture_period > 500)) {
|
||||
mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500"));
|
||||
}
|
||||
mp_arg_validate_int_range(capture_period, 1, 500, MP_QSTR_capture_period);
|
||||
|
||||
self->capture_period = capture_period;
|
||||
common_hal_frequencyio_frequencyin_clear(self);
|
||||
timer_set_alarm_value(self->timer.group, self->timer.idx, capture_period * 1000000);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "py/runtime.h"
|
||||
|
||||
#include "common-hal/i2cperipheral/I2CPeripheral.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_peripheral_obj_t *self,
|
||||
const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda,
|
||||
|
@ -39,7 +40,7 @@ void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_periphe
|
|||
// support I2C on these pins.
|
||||
// Also 46 is input-only so it'll never work.
|
||||
if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
|
||||
if (num_addresses > 1) {
|
||||
|
@ -72,7 +73,7 @@ void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_periphe
|
|||
if (err == ESP_FAIL) {
|
||||
mp_raise_OSError(MP_EIO);
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid argument"));
|
||||
mp_arg_error_invalid(MP_QSTR_I2CPeripheral);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle
|
|||
const mcu_pin_obj_t *horizontal_reference) {
|
||||
|
||||
// only 8 bits is supported at present
|
||||
if (data_count < 8 || data_count > 16) {
|
||||
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_data_count, 8, 16);
|
||||
}
|
||||
mp_arg_validate_int_range(data_count, 8, 16, MP_QSTR_data_count);
|
||||
|
||||
// This will throw if unsuccessful. Everything following is guaranteed to succeed.
|
||||
port_i2s_allocate_i2s0();
|
||||
|
|
|
@ -88,7 +88,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu
|
|||
uint16_t maxlen, bool idle_state) {
|
||||
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
|
||||
if (self->buffer == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
|
||||
m_malloc_fail(maxlen * sizeof(uint16_t));
|
||||
}
|
||||
self->pin = pin;
|
||||
self->maxlen = maxlen;
|
||||
|
|
|
@ -217,7 +217,7 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t fr
|
|||
// Calculate duty cycle
|
||||
uint32_t duty_bits = calculate_duty_cycle(frequency);
|
||||
if (duty_bits == 0) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
self->duty_resolution = duty_bits;
|
||||
ledc_set_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num, frequency);
|
||||
|
|
|
@ -48,5 +48,5 @@ int common_hal_rtc_get_calibration(void) {
|
|||
}
|
||||
|
||||
void common_hal_rtc_set_calibration(int calibration) {
|
||||
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
|
||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "py/runtime.h"
|
||||
#include "peripherals/touch.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
|
||||
uint32_t touch_value;
|
||||
|
@ -41,7 +42,7 @@ static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
|
|||
void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
if (pin->touch_channel == TOUCH_PAD_MAX) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
claim_pin(pin);
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_
|
|||
authmode = WIFI_AUTH_WPA_WPA2_PSK;
|
||||
break;
|
||||
default:
|
||||
mp_raise_ValueError(translate("Invalid AuthMode"));
|
||||
mp_arg_error_invalid(MP_QSTR_authmode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,8 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_
|
|||
config->ap.channel = channel;
|
||||
config->ap.authmode = authmode;
|
||||
|
||||
if (max_connections < 0 || max_connections > 10) {
|
||||
mp_raise_ValueError(translate("max_connections must be between 0 and 10"));
|
||||
}
|
||||
mp_arg_validate_int_range(max_connections, 0, 10, MP_QSTR_max_connections);
|
||||
|
||||
config->ap.max_connection = max_connections;
|
||||
|
||||
esp_wifi_set_config(WIFI_IF_AP, config);
|
||||
|
|
|
@ -42,7 +42,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
|
|||
adc_config_t config = {0};
|
||||
|
||||
if (pin->adc == NULL) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
|
||||
ADC_GetDefaultConfig(&config);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "supervisor/shared/translate.h"
|
||||
|
||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) {
|
||||
mp_raise_NotImplementedError(translate("AnalogOut functionality not supported"));
|
||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut);
|
||||
}
|
||||
|
||||
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
||||
|
|
|
@ -138,7 +138,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
|||
}
|
||||
|
||||
if (self->sda == NULL || self->scl == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
} else {
|
||||
self->i2c = mcu_i2c_banks[self->sda->bank_idx - 1];
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||
if (spi_taken) {
|
||||
mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,12 +113,9 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
bool sigint_enabled) {
|
||||
|
||||
self->baudrate = baudrate;
|
||||
self->character_bits = bits;
|
||||
self->character_bits = (uint8_t)mp_arg_validate_int_range(self->character_bits, 7, 8, MP_QSTR_bits);
|
||||
self->timeout_ms = timeout * 1000;
|
||||
|
||||
if (self->character_bits != 7 && self->character_bits != 8) {
|
||||
mp_raise_ValueError(translate("Invalid word/bit length"));
|
||||
}
|
||||
|
||||
DBGPrintf(&mp_plat_print, "uart_construct: tx:%p rx:%p rts:%p cts:%p rs485:%p\n", tx, rx, rts, cts, rs485_dir);
|
||||
|
||||
|
@ -186,10 +183,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
|
||||
if (rx && !rx_config) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_RX);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_rx);
|
||||
}
|
||||
if (tx && !tx_config) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_TX);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_tx);
|
||||
}
|
||||
|
||||
if (uart_taken) {
|
||||
|
@ -236,7 +233,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
}
|
||||
if ((rts != NULL) && (rts_config == NULL)) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_RTS);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_rts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,7 +247,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
}
|
||||
}
|
||||
if (cts_config == NULL) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_CTS);
|
||||
raise_ValueError_invalid_pin_name(MP_QSTR_cts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +347,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
|
||||
if (!self->ringbuf) {
|
||||
LPUART_Deinit(self->uart);
|
||||
mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer"));
|
||||
m_malloc_fail(receiver_buffer_size);
|
||||
}
|
||||
|
||||
LPUART_TransferCreateHandle(self->uart, &self->handle, LPUART_UserCallback, self);
|
||||
|
|
|
@ -70,7 +70,7 @@ void common_hal_mcu_enable_interrupts(void) {
|
|||
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
|
||||
if (runmode == RUNMODE_BOOTLOADER) {
|
||||
if (!bootloader_available()) {
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present."));
|
||||
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
|
||||
}
|
||||
// Pretend to be the first of the two reset presses needed to enter the
|
||||
// bootloader. That way one reset will end in the bootloader.
|
||||
|
|
|
@ -301,7 +301,7 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self,
|
|||
|
||||
int pulse_count = calculate_pulse_count(frequency, &self->prescaler);
|
||||
if (pulse_count == 0) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
mp_arg_error_invalid(MP_QSTR_frequency);
|
||||
}
|
||||
|
||||
self->pulse_count = pulse_count;
|
||||
|
|
|
@ -75,5 +75,5 @@ int common_hal_rtc_get_calibration(void) {
|
|||
|
||||
void common_hal_rtc_set_calibration(int calibration) {
|
||||
// SNVS has HPCALB_VAL bits for calibration.
|
||||
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
|
||||
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/usb_host/Port.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/usb_host/Port.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
|
@ -43,7 +42,7 @@ void common_hal_usb_host_port_construct(usb_host_port_obj_t *self, const mcu_pin
|
|||
supported_dm = &pin_USB_OTG2_DN;
|
||||
}
|
||||
if (dp != supported_dp || dm != supported_dm) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
raise_ValueError_invalid_pins();
|
||||
}
|
||||
self->init = true;
|
||||
usb_host_init = true;
|
||||
|
|
|
@ -49,10 +49,10 @@ extern uint32_t reset_reason_saved;
|
|||
|
||||
void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) {
|
||||
if (edge) {
|
||||
mp_raise_ValueError(translate("Cannot wake on pin edge. Only level."));
|
||||
mp_raise_ValueError(translate("Cannot wake on pin edge, only level"));
|
||||
}
|
||||
if (pin->number >= NUMBER_OF_PINS) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
raise_ValueError_invalid_pin();
|
||||
}
|
||||
self->pin = pin;
|
||||
self->value = value;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue