summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/machine_hspi.c
diff options
context:
space:
mode:
authorJavier Candeira <javier@candeira.com>2017-08-09 14:40:45 +1000
committerJavier Candeira <javier@candeira.com>2017-08-13 22:52:33 +1000
commit35a1fea90b2cae9d5cc8e9eab62ba4c67e8786db (patch)
tree26616de189a9154309287846bf76fb1cdab8ce51 /esp8266/machine_hspi.c
parentb6a328956467339f568b19d9192fbbfdfa47a572 (diff)
downloadmicropython-35a1fea90b2cae9d5cc8e9eab62ba4c67e8786db.tar.gz
micropython-35a1fea90b2cae9d5cc8e9eab62ba4c67e8786db.zip
all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError - OSError invocations unchanged, because the corresponding utility function takes ints, not strings like the long form invocation. - OverflowError, IndexError and RuntimeError etc. not changed for now until we decide whether to add new utility functions.
Diffstat (limited to 'esp8266/machine_hspi.c')
-rw-r--r--esp8266/machine_hspi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/esp8266/machine_hspi.c b/esp8266/machine_hspi.c
index 1be342b526..eaabbab7ea 100644
--- a/esp8266/machine_hspi.c
+++ b/esp8266/machine_hspi.c
@@ -122,15 +122,13 @@ STATIC void machine_hspi_init(mp_obj_base_t *self_in, size_t n_args, const mp_ob
spi_init_gpio(HSPI, SPI_CLK_80MHZ_NODIV);
spi_clock(HSPI, 0, 0);
} else if (self->baudrate > 40000000L) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
- "impossible baudrate"));
+ mp_raise_ValueError("impossible baudrate");
} else {
uint32_t divider = 40000000L / self->baudrate;
uint16_t prediv = MIN(divider, SPI_CLKDIV_PRE + 1);
uint16_t cntdiv = (divider / prediv) * 2; // cntdiv has to be even
if (cntdiv > SPI_CLKCNT_N + 1 || cntdiv == 0 || prediv == 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
- "impossible baudrate"));
+ mp_raise_ValueError("impossible baudrate");
}
self->baudrate = 80000000L / (prediv * cntdiv);
spi_init_gpio(HSPI, SPI_CLK_USE_DIV);