summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-02 15:02:57 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-02 15:02:57 +1100
commit6ab5512132d5b3d19a5bf029cb27829d41e76f8e (patch)
treed1dc10771b963ac3be632b2ba90e2499321d83ea
parent1f549a3496ac543390a170a7eb7b242475063016 (diff)
downloadmicropython-6ab5512132d5b3d19a5bf029cb27829d41e76f8e.tar.gz
micropython-6ab5512132d5b3d19a5bf029cb27829d41e76f8e.zip
stmhal: Use mp_hal_delay_ms instead of HAL_Delay.
-rw-r--r--stmhal/accel.c6
-rw-r--r--stmhal/i2c.c2
-rw-r--r--stmhal/lcd.c6
-rw-r--r--stmhal/led.c2
-rw-r--r--stmhal/main.c24
-rw-r--r--stmhal/modmachine.c2
-rw-r--r--stmhal/modnwcc3k.c2
-rw-r--r--stmhal/modnwwiznet5k.c8
-rw-r--r--stmhal/sdcard.c2
9 files changed, 27 insertions, 27 deletions
diff --git a/stmhal/accel.c b/stmhal/accel.c
index 827e9177a0..2e3504b06e 100644
--- a/stmhal/accel.c
+++ b/stmhal/accel.c
@@ -76,9 +76,9 @@ STATIC void accel_start(void) {
// turn off AVDD, wait 30ms, turn on AVDD, wait 30ms again
mp_hal_pin_low(&MICROPY_HW_MMA_AVDD_PIN); // turn off
- HAL_Delay(30);
+ mp_hal_delay_ms(30);
mp_hal_pin_high(&MICROPY_HW_MMA_AVDD_PIN); // turn on
- HAL_Delay(30);
+ mp_hal_delay_ms(30);
HAL_StatusTypeDef status;
@@ -98,7 +98,7 @@ STATIC void accel_start(void) {
status = HAL_I2C_Mem_Write(&I2CHandle1, MMA_ADDR, MMA_REG_MODE, I2C_MEMADD_SIZE_8BIT, data, 1, 200);
// wait for MMA to become active
- HAL_Delay(30);
+ mp_hal_delay_ms(30);
}
/******************************************************************************/
diff --git a/stmhal/i2c.c b/stmhal/i2c.c
index 29c350d22f..412a8e3638 100644
--- a/stmhal/i2c.c
+++ b/stmhal/i2c.c
@@ -346,7 +346,7 @@ STATIC void i2c_reset_after_error(I2C_HandleTypeDef *i2c) {
// stop bit was generated and bus is back to normal
return;
}
- HAL_Delay(1);
+ mp_hal_delay_ms(1);
}
// bus was/is busy, need to reset the peripheral to get it to work again
i2c_deinit(i2c);
diff --git a/stmhal/lcd.c b/stmhal/lcd.c
index e73b6e16d3..cde6c36f67 100644
--- a/stmhal/lcd.c
+++ b/stmhal/lcd.c
@@ -274,11 +274,11 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_
mp_hal_pin_output(lcd->pin_bl);
// init the LCD
- HAL_Delay(1); // wait a bit
+ mp_hal_delay_ms(1); // wait a bit
mp_hal_pin_low(lcd->pin_rst); // RST=0; reset
- HAL_Delay(1); // wait for reset; 2us min
+ mp_hal_delay_ms(1); // wait for reset; 2us min
mp_hal_pin_high(lcd->pin_rst); // RST=1; enable
- HAL_Delay(1); // wait for reset; 2us min
+ mp_hal_delay_ms(1); // wait for reset; 2us min
lcd_out(lcd, LCD_INSTR, 0xa0); // ADC select, normal
lcd_out(lcd, LCD_INSTR, 0xc0); // common output mode select, normal (this flips the display)
lcd_out(lcd, LCD_INSTR, 0xa2); // LCD bias set, 1/9 bias
diff --git a/stmhal/led.c b/stmhal/led.c
index 357aed4074..be98aa4a4d 100644
--- a/stmhal/led.c
+++ b/stmhal/led.c
@@ -275,7 +275,7 @@ void led_debug(int n, int delay) {
led_state(2, n & 2);
led_state(3, n & 4);
led_state(4, n & 8);
- HAL_Delay(delay);
+ mp_hal_delay_ms(delay);
}
/******************************************************************************/
diff --git a/stmhal/main.c b/stmhal/main.c
index c6d482f3ce..e07f6cf8c5 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -71,10 +71,10 @@ void flash_error(int n) {
for (int i = 0; i < n; i++) {
led_state(PYB_LED_RED, 1);
led_state(PYB_LED_GREEN, 0);
- HAL_Delay(250);
+ mp_hal_delay_ms(250);
led_state(PYB_LED_RED, 0);
led_state(PYB_LED_GREEN, 1);
- HAL_Delay(250);
+ mp_hal_delay_ms(250);
}
led_state(PYB_LED_GREEN, 0);
}
@@ -349,7 +349,7 @@ STATIC uint update_reset_mode(uint reset_mode) {
if (!switch_get()) {
break;
}
- HAL_Delay(20);
+ mp_hal_delay_ms(20);
if (i % 30 == 29) {
if (++reset_mode > 3) {
reset_mode = 1;
@@ -364,13 +364,13 @@ STATIC uint update_reset_mode(uint reset_mode) {
led_state(2, 0);
led_state(3, 0);
led_state(4, 0);
- HAL_Delay(50);
+ mp_hal_delay_ms(50);
led_state(2, reset_mode & 1);
led_state(3, reset_mode & 2);
led_state(4, reset_mode & 4);
- HAL_Delay(50);
+ mp_hal_delay_ms(50);
}
- HAL_Delay(400);
+ mp_hal_delay_ms(400);
#elif defined(MICROPY_HW_LED1)
@@ -383,11 +383,11 @@ STATIC uint update_reset_mode(uint reset_mode) {
break;
}
led_state(1, 1);
- HAL_Delay(100);
+ mp_hal_delay_ms(100);
led_state(1, 0);
- HAL_Delay(200);
+ mp_hal_delay_ms(200);
}
- HAL_Delay(400);
+ mp_hal_delay_ms(400);
if (!switch_get()) {
break;
}
@@ -399,11 +399,11 @@ STATIC uint update_reset_mode(uint reset_mode) {
for (uint i = 0; i < 2; i++) {
for (uint j = 0; j < reset_mode; j++) {
led_state(1, 1);
- HAL_Delay(100);
+ mp_hal_delay_ms(100);
led_state(1, 0);
- HAL_Delay(200);
+ mp_hal_delay_ms(200);
}
- HAL_Delay(400);
+ mp_hal_delay_ms(400);
}
#else
#error Need a reset mode update method
diff --git a/stmhal/modmachine.c b/stmhal/modmachine.c
index 16c50079d1..d615a0f2b7 100644
--- a/stmhal/modmachine.c
+++ b/stmhal/modmachine.c
@@ -324,7 +324,7 @@ STATIC mp_obj_t machine_freq(mp_uint_t n_args, const mp_obj_t *args) {
//printf("%lu %lu %lu %lu %lu\n", sysclk_source, m, n, p, q);
// let the USB CDC have a chance to process before we change the clock
- HAL_Delay(5);
+ mp_hal_delay_ms(5);
// desired system clock source is in sysclk_source
RCC_ClkInitTypeDef RCC_ClkInitStruct;
diff --git a/stmhal/modnwcc3k.c b/stmhal/modnwcc3k.c
index 19aeabf5ce..753ab7528e 100644
--- a/stmhal/modnwcc3k.c
+++ b/stmhal/modnwcc3k.c
@@ -120,7 +120,7 @@ STATIC int cc3k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uin
if (retry == 0 || CC3000_EXPORT(errno) != -95) {
return CC3000_EXPORT(errno);
}
- HAL_Delay(50);
+ mp_hal_delay_ms(50);
}
if (ip == 0) {
diff --git a/stmhal/modnwwiznet5k.c b/stmhal/modnwwiznet5k.c
index 04d37cceef..e3d5c6370c 100644
--- a/stmhal/modnwwiznet5k.c
+++ b/stmhal/modnwwiznet5k.c
@@ -202,7 +202,7 @@ STATIC int wiznet5k_socket_accept(mod_network_socket_obj_t *socket, mod_network_
*_errno = MP_ENOTCONN; // ??
return -1;
}
- HAL_Delay(1);
+ mp_hal_delay_ms(1);
}
}
@@ -348,9 +348,9 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
mp_hal_pin_output(wiznet5k_obj.rst);
mp_hal_pin_low(wiznet5k_obj.rst);
- HAL_Delay(1); // datasheet says 2us
+ mp_hal_delay_ms(1); // datasheet says 2us
mp_hal_pin_high(wiznet5k_obj.rst);
- HAL_Delay(160); // datasheet says 150ms
+ mp_hal_delay_ms(160); // datasheet says 150ms
reg_wizchip_cris_cbfunc(wiz_cris_enter, wiz_cris_exit);
reg_wizchip_cs_cbfunc(wiz_cs_select, wiz_cs_deselect);
@@ -371,7 +371,7 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
ctlnetwork(CN_SET_NETINFO, (void*)&netinfo);
// seems we need a small delay after init
- HAL_Delay(250);
+ mp_hal_delay_ms(250);
// register with network module
mod_network_register_nic(&wiznet5k_obj);
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 6e9c46df54..c93b98b51e 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -145,7 +145,7 @@ bool sdcard_power_on(void) {
if (retry == 0) {
goto error;
}
- HAL_Delay(50);
+ mp_hal_delay_ms(50);
}
// configure the SD bus width for wide operation