Commit ecc88e94 authored by Damien George's avatar Damien George
Browse files

Change some parts of the core API to use mp_uint_t instead of uint/int.

Addressing issue #50, still some way to go yet.
parent 4d3fc463
...@@ -222,7 +222,7 @@ STATIC const mp_arg_t pyb_i2c_init_args[] = { ...@@ -222,7 +222,7 @@ STATIC const mp_arg_t pyb_i2c_init_args[] = {
}; };
#define PYB_I2C_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_init_args) #define PYB_I2C_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_init_args)
STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args // parse args
mp_arg_val_t vals[PYB_I2C_INIT_NUM_ARGS]; mp_arg_val_t vals[PYB_I2C_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PYB_I2C_INIT_NUM_ARGS, pyb_i2c_init_args, vals); mp_arg_parse_all(n_args, args, kw_args, PYB_I2C_INIT_NUM_ARGS, pyb_i2c_init_args, vals);
...@@ -263,7 +263,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, uint n_args, cons ...@@ -263,7 +263,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, uint n_args, cons
/// ///
/// - `I2C(1)` is on the X position: `(SCL, SDA) = (X9, X10) = (PB6, PB7)` /// - `I2C(1)` is on the X position: `(SCL, SDA) = (X9, X10) = (PB6, PB7)`
/// - `I2C(2)` is on the Y position: `(SCL, SDA) = (Y9, Y10) = (PB10, PB11)` /// - `I2C(2)` is on the Y position: `(SCL, SDA) = (Y9, Y10) = (PB10, PB11)`
STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
...@@ -288,7 +288,7 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const ...@@ -288,7 +288,7 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
return (mp_obj_t)i2c_obj; return (mp_obj_t)i2c_obj;
} }
STATIC mp_obj_t pyb_i2c_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_i2c_init_helper(args[0], n_args - 1, args + 1, kw_args); return pyb_i2c_init_helper(args[0], n_args - 1, args + 1, kw_args);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init);
...@@ -365,7 +365,7 @@ STATIC const mp_arg_t pyb_i2c_send_args[] = { ...@@ -365,7 +365,7 @@ STATIC const mp_arg_t pyb_i2c_send_args[] = {
}; };
#define PYB_I2C_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_send_args) #define PYB_I2C_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_send_args)
STATIC mp_obj_t pyb_i2c_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
pyb_i2c_obj_t *self = args[0]; pyb_i2c_obj_t *self = args[0];
// parse args // parse args
...@@ -416,7 +416,7 @@ STATIC const mp_arg_t pyb_i2c_recv_args[] = { ...@@ -416,7 +416,7 @@ STATIC const mp_arg_t pyb_i2c_recv_args[] = {
}; };
#define PYB_I2C_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_recv_args) #define PYB_I2C_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_recv_args)
STATIC mp_obj_t pyb_i2c_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
pyb_i2c_obj_t *self = args[0]; pyb_i2c_obj_t *self = args[0];
// parse args // parse args
...@@ -474,7 +474,7 @@ STATIC const mp_arg_t pyb_i2c_mem_read_args[] = { ...@@ -474,7 +474,7 @@ STATIC const mp_arg_t pyb_i2c_mem_read_args[] = {
}; };
#define PYB_I2C_MEM_READ_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_mem_read_args) #define PYB_I2C_MEM_READ_NUM_ARGS MP_ARRAY_SIZE(pyb_i2c_mem_read_args)
STATIC mp_obj_t pyb_i2c_mem_read(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_mem_read(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
pyb_i2c_obj_t *self = args[0]; pyb_i2c_obj_t *self = args[0];
if (!in_master_mode(self)) { if (!in_master_mode(self)) {
...@@ -526,7 +526,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_mem_read_obj, 1, pyb_i2c_mem_read); ...@@ -526,7 +526,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_mem_read_obj, 1, pyb_i2c_mem_read);
/// ///
/// Returns `None`. /// Returns `None`.
/// This is only valid in master mode. /// This is only valid in master mode.
STATIC mp_obj_t pyb_i2c_mem_write(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_i2c_mem_write(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
pyb_i2c_obj_t *self = args[0]; pyb_i2c_obj_t *self = args[0];
if (!in_master_mode(self)) { if (!in_master_mode(self)) {
......
...@@ -198,7 +198,7 @@ STATIC void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len ...@@ -198,7 +198,7 @@ STATIC void lcd_write_strn(pyb_lcd_obj_t *lcd, const char *str, unsigned int len
/// ///
/// Construct an LCD object in the given skin position. `skin_position` can be 'X' or 'Y', and /// Construct an LCD object in the given skin position. `skin_position` can be 'X' or 'Y', and
/// should match the position where the LCD pyskin is plugged in. /// should match the position where the LCD pyskin is plugged in.
STATIC mp_obj_t pyb_lcd_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_lcd_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_arg_check_num(n_args, n_kw, 1, 1, false);
...@@ -437,7 +437,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get); ...@@ -437,7 +437,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_lcd_get_obj, pyb_lcd_get);
/// Set the pixel at `(x, y)` to the given colour (0 or 1). /// Set the pixel at `(x, y)` to the given colour (0 or 1).
/// ///
/// This method writes to the hidden buffer. Use `show()` to show the buffer. /// This method writes to the hidden buffer. Use `show()` to show the buffer.
STATIC mp_obj_t pyb_lcd_pixel(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_lcd_pixel(mp_uint_t n_args, const mp_obj_t *args) {
pyb_lcd_obj_t *self = args[0]; pyb_lcd_obj_t *self = args[0];
int x = mp_obj_get_int(args[1]); int x = mp_obj_get_int(args[1]);
int y = mp_obj_get_int(args[2]); int y = mp_obj_get_int(args[2]);
...@@ -458,7 +458,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe ...@@ -458,7 +458,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe
/// Draw the given text to the position `(x, y)` using the given colour (0 or 1). /// Draw the given text to the position `(x, y)` using the given colour (0 or 1).
/// ///
/// This method writes to the hidden buffer. Use `show()` to show the buffer. /// This method writes to the hidden buffer. Use `show()` to show the buffer.
STATIC mp_obj_t pyb_lcd_text(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_lcd_text(mp_uint_t n_args, const mp_obj_t *args) {
// extract arguments // extract arguments
pyb_lcd_obj_t *self = args[0]; pyb_lcd_obj_t *self = args[0];
uint len; uint len;
......
...@@ -221,7 +221,7 @@ void led_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp ...@@ -221,7 +221,7 @@ void led_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp
/// Create an LED object associated with the given LED: /// Create an LED object associated with the given LED:
/// ///
/// - `id` is the LED number, 1-4. /// - `id` is the LED number, 1-4.
STATIC mp_obj_t led_obj_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t led_obj_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_arg_check_num(n_args, n_kw, 1, 1, false);
...@@ -265,7 +265,7 @@ mp_obj_t led_obj_toggle(mp_obj_t self_in) { ...@@ -265,7 +265,7 @@ mp_obj_t led_obj_toggle(mp_obj_t self_in) {
/// Get or set the LED intensity. Intensity ranges between 0 (off) and 255 (full on). /// Get or set the LED intensity. Intensity ranges between 0 (off) and 255 (full on).
/// If no argument is given, return the LED intensity. /// If no argument is given, return the LED intensity.
/// If an argument is given, set the LED intensity and return `None`. /// If an argument is given, set the LED intensity and return `None`.
mp_obj_t led_obj_intensity(uint n_args, const mp_obj_t *args) { mp_obj_t led_obj_intensity(mp_uint_t n_args, const mp_obj_t *args) {
pyb_led_obj_t *self = args[0]; pyb_led_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
return mp_obj_new_int(led_get_intensity(self->led_id)); return mp_obj_new_int(led_get_intensity(self->led_id));
......
...@@ -104,7 +104,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); ...@@ -104,7 +104,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd);
/// \function listdir([dir]) /// \function listdir([dir])
/// With no argument, list the current directory. Otherwise list the given directory. /// With no argument, list the current directory. Otherwise list the given directory.
STATIC mp_obj_t os_listdir(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t os_listdir(mp_uint_t n_args, const mp_obj_t *args) {
bool is_str_type = true; bool is_str_type = true;
const char *path; const char *path;
if (n_args == 1) { if (n_args == 1) {
......
...@@ -188,7 +188,7 @@ STATIC void mod_time_seconds_since_2000_to_struct_time(mp_uint_t t, mod_struct_t ...@@ -188,7 +188,7 @@ STATIC void mod_time_seconds_since_2000_to_struct_time(mp_uint_t t, mod_struct_t
/// second is 0-59 /// second is 0-59
/// weekday is 0-6 for Mon-Sun. /// weekday is 0-6 for Mon-Sun.
/// yearday is 1-366 /// yearday is 1-366
STATIC mp_obj_t time_localtime(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t time_localtime(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 0 || args[0] == mp_const_none) { if (n_args == 0 || args[0] == mp_const_none) {
// get current date and time // get current date and time
// note: need to call get time then get date to correctly access the registers // note: need to call get time then get date to correctly access the registers
......
...@@ -245,12 +245,12 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env, ...@@ -245,12 +245,12 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env,
} }
} }
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *pin, uint n_args, const mp_obj_t *args, mp_map_t *kw_args); STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *pin, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
/// \classmethod \constructor(id, ...) /// \classmethod \constructor(id, ...)
/// Create a new Pin object associated with the id. If additional arguments are given, /// Create a new Pin object associated with the id. If additional arguments are given,
/// they are used to initialise the pin. See `init`. /// they are used to initialise the pin. See `init`.
STATIC mp_obj_t pin_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pin_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
// Run an argument through the mapper and return the result. // Run an argument through the mapper and return the result.
...@@ -268,7 +268,7 @@ STATIC mp_obj_t pin_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_ ...@@ -268,7 +268,7 @@ STATIC mp_obj_t pin_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_
/// \classmethod mapper([fun]) /// \classmethod mapper([fun])
/// Get or set the pin mapper function. /// Get or set the pin mapper function.
STATIC mp_obj_t pin_mapper(uint n_args, mp_obj_t *args) { STATIC mp_obj_t pin_mapper(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args > 1) { if (n_args > 1) {
pin_class_mapper = args[1]; pin_class_mapper = args[1];
return mp_const_none; return mp_const_none;
...@@ -280,7 +280,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_mapper_obj, (mp_obj_t)&pin_mapper_fun ...@@ -280,7 +280,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_mapper_obj, (mp_obj_t)&pin_mapper_fun
/// \classmethod dict([dict]) /// \classmethod dict([dict])
/// Get or set the pin mapper dictionary. /// Get or set the pin mapper dictionary.
STATIC mp_obj_t pin_map_dict(uint n_args, mp_obj_t *args) { STATIC mp_obj_t pin_map_dict(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args > 1) { if (n_args > 1) {
pin_class_map_dict = args[1]; pin_class_map_dict = args[1];
return mp_const_none; return mp_const_none;
...@@ -306,7 +306,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_af_list_obj, pin_af_list); ...@@ -306,7 +306,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_af_list_obj, pin_af_list);
/// \classmethod debug([state]) /// \classmethod debug([state])
/// Get or set the debugging state (`True` or `False` for on or off). /// Get or set the debugging state (`True` or `False` for on or off).
STATIC mp_obj_t pin_debug(uint n_args, mp_obj_t *args) { STATIC mp_obj_t pin_debug(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args > 1) { if (n_args > 1) {
pin_class_debug = mp_obj_is_true(args[1]); pin_class_debug = mp_obj_is_true(args[1]);
return mp_const_none; return mp_const_none;
...@@ -341,7 +341,7 @@ STATIC const mp_arg_t pin_init_args[] = { ...@@ -341,7 +341,7 @@ STATIC const mp_arg_t pin_init_args[] = {
}; };
#define PIN_INIT_NUM_ARGS MP_ARRAY_SIZE(pin_init_args) #define PIN_INIT_NUM_ARGS MP_ARRAY_SIZE(pin_init_args)
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args // parse args
mp_arg_val_t vals[PIN_INIT_NUM_ARGS]; mp_arg_val_t vals[PIN_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PIN_INIT_NUM_ARGS, pin_init_args, vals); mp_arg_parse_all(n_args, args, kw_args, PIN_INIT_NUM_ARGS, pin_init_args, vals);
...@@ -410,7 +410,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp ...@@ -410,7 +410,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp
return mp_const_none; return mp_const_none;
} }
STATIC mp_obj_t pin_obj_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pin_obj_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args); return pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
...@@ -422,7 +422,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init); ...@@ -422,7 +422,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
/// - With `value` given, set the logic level of the pin. `value` can be /// - With `value` given, set the logic level of the pin. `value` can be
/// anything that converts to a boolean. If it converts to `True`, the pin /// anything that converts to a boolean. If it converts to `True`, the pin
/// is set high, otherwise it is set low. /// is set high, otherwise it is set low.
STATIC mp_obj_t pin_value(uint n_args, mp_obj_t *args) { STATIC mp_obj_t pin_value(mp_uint_t n_args, const mp_obj_t *args) {
pin_obj_t *self = args[0]; pin_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get pin // get pin
......
...@@ -140,7 +140,7 @@ STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size, ...@@ -140,7 +140,7 @@ STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size,
} }
} }
mp_obj_t stdio_obj___exit__(uint n_args, const mp_obj_t *args) { mp_obj_t stdio_obj___exit__(mp_uint_t n_args, const mp_obj_t *args) {
return mp_const_none; return mp_const_none;
} }
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__); static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__);
......
...@@ -253,7 +253,7 @@ STATIC const pyb_rtc_obj_t pyb_rtc_obj = {{&pyb_rtc_type}}; ...@@ -253,7 +253,7 @@ STATIC const pyb_rtc_obj_t pyb_rtc_obj = {{&pyb_rtc_type}};
/// \classmethod \constructor() /// \classmethod \constructor()
/// Create an RTC object. /// Create an RTC object.
STATIC mp_obj_t pyb_rtc_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_rtc_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 0, 0, false); mp_arg_check_num(n_args, n_kw, 0, 0, false);
...@@ -287,7 +287,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pyb_rtc_info_obj, pyb_rtc_info); ...@@ -287,7 +287,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pyb_rtc_info_obj, pyb_rtc_info);
/// `weekday` is 1-7 for Monday through Sunday. /// `weekday` is 1-7 for Monday through Sunday.
/// ///
/// `subseconds` counts down from 255 to 0 /// `subseconds` counts down from 255 to 0
mp_obj_t pyb_rtc_datetime(uint n_args, const mp_obj_t *args) { mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 1) { if (n_args == 1) {
// get date and time // get date and time
// note: need to call get time then get date to correctly access the registers // note: need to call get time then get date to correctly access the registers
......
...@@ -189,7 +189,7 @@ STATIC void pyb_servo_print(void (*print)(void *env, const char *fmt, ...), void ...@@ -189,7 +189,7 @@ STATIC void pyb_servo_print(void (*print)(void *env, const char *fmt, ...), void
/// \classmethod \constructor(id) /// \classmethod \constructor(id)
/// Create a servo object. `id` is 1-4. /// Create a servo object. `id` is 1-4.
STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_arg_check_num(n_args, n_kw, 1, 1, false);
...@@ -212,7 +212,7 @@ STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con ...@@ -212,7 +212,7 @@ STATIC mp_obj_t pyb_servo_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
/// \method pulse_width([value]) /// \method pulse_width([value])
/// Get or set the pulse width in milliseconds. /// Get or set the pulse width in milliseconds.
STATIC mp_obj_t pyb_servo_pulse_width(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_servo_pulse_width(mp_uint_t n_args, const mp_obj_t *args) {
pyb_servo_obj_t *self = args[0]; pyb_servo_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get pulse width, in us // get pulse width, in us
...@@ -230,7 +230,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_pulse_width_obj, 1, 2, pyb_ ...@@ -230,7 +230,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_pulse_width_obj, 1, 2, pyb_
/// \method calibration([pulse_min, pulse_max, pulse_centre, [pulse_angle_90, pulse_speed_100]]) /// \method calibration([pulse_min, pulse_max, pulse_centre, [pulse_angle_90, pulse_speed_100]])
/// Get or set the calibration of the servo timing. /// Get or set the calibration of the servo timing.
// TODO should accept 1 arg, a 5-tuple of values to set // TODO should accept 1 arg, a 5-tuple of values to set
STATIC mp_obj_t pyb_servo_calibration(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_servo_calibration(mp_uint_t n_args, const mp_obj_t *args) {
pyb_servo_obj_t *self = args[0]; pyb_servo_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get calibration values // get calibration values
...@@ -265,7 +265,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_calibration_obj, 1, 6, pyb_ ...@@ -265,7 +265,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_calibration_obj, 1, 6, pyb_
/// ///
/// - `angle` is the angle to move to in degrees. /// - `angle` is the angle to move to in degrees.
/// - `time` is the number of milliseconds to take to get to the specified angle. /// - `time` is the number of milliseconds to take to get to the specified angle.
STATIC mp_obj_t pyb_servo_angle(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_servo_angle(mp_uint_t n_args, const mp_obj_t *args) {
pyb_servo_obj_t *self = args[0]; pyb_servo_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get angle // get angle
...@@ -295,7 +295,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_angle_obj, 1, 3, pyb_servo_ ...@@ -295,7 +295,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_servo_angle_obj, 1, 3, pyb_servo_
/// ///
/// - `speed` is the speed to move to change to, between -100 and 100. /// - `speed` is the speed to move to change to, between -100 and 100.
/// - `time` is the number of milliseconds to take to get to the specified speed. /// - `time` is the number of milliseconds to take to get to the specified speed.
STATIC mp_obj_t pyb_servo_speed(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t pyb_servo_speed(mp_uint_t n_args, const mp_obj_t *args) {
pyb_servo_obj_t *self = args[0]; pyb_servo_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get speed // get speed
......
...@@ -244,7 +244,7 @@ STATIC const mp_arg_t pyb_spi_init_args[] = { ...@@ -244,7 +244,7 @@ STATIC const mp_arg_t pyb_spi_init_args[] = {
}; };
#define PYB_SPI_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_init_args) #define PYB_SPI_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_init_args)
STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args // parse args
mp_arg_val_t vals[PYB_SPI_INIT_NUM_ARGS]; mp_arg_val_t vals[PYB_SPI_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PYB_SPI_INIT_NUM_ARGS, pyb_spi_init_args, vals); mp_arg_parse_all(n_args, args, kw_args, PYB_SPI_INIT_NUM_ARGS, pyb_spi_init_args, vals);
...@@ -309,7 +309,7 @@ STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, cons ...@@ -309,7 +309,7 @@ STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, uint n_args, cons
/// ///
/// At the moment, the NSS pin is not used by the SPI driver and is free /// At the moment, the NSS pin is not used by the SPI driver and is free
/// for other use. /// for other use.
STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
...@@ -334,7 +334,7 @@ STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const ...@@ -334,7 +334,7 @@ STATIC mp_obj_t pyb_spi_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
return (mp_obj_t)spi_obj; return (mp_obj_t)spi_obj;
} }
STATIC mp_obj_t pyb_spi_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_spi_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_spi_init_helper(args[0], n_args - 1, args + 1, kw_args); return pyb_spi_init_helper(args[0], n_args - 1, args + 1, kw_args);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_spi_init_obj, 1, pyb_spi_init); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_spi_init_obj, 1, pyb_spi_init);
...@@ -361,7 +361,7 @@ STATIC const mp_arg_t pyb_spi_send_args[] = { ...@@ -361,7 +361,7 @@ STATIC const mp_arg_t pyb_spi_send_args[] = {
}; };
#define PYB_SPI_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_args) #define PYB_SPI_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_args)
STATIC mp_obj_t pyb_spi_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_spi_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO assumes transmission size is 8-bits wide // TODO assumes transmission size is 8-bits wide
pyb_spi_obj_t *self = args[0]; pyb_spi_obj_t *self = args[0];
...@@ -403,7 +403,7 @@ STATIC const mp_arg_t pyb_spi_recv_args[] = { ...@@ -403,7 +403,7 @@ STATIC const mp_arg_t pyb_spi_recv_args[] = {
}; };
#define PYB_SPI_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_recv_args) #define PYB_SPI_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_recv_args)
STATIC mp_obj_t pyb_spi_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_spi_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO assumes transmission size is 8-bits wide // TODO assumes transmission size is 8-bits wide
pyb_spi_obj_t *self = args[0]; pyb_spi_obj_t *self = args[0];
...@@ -451,7 +451,7 @@ STATIC const mp_arg_t pyb_spi_send_recv_args[] = { ...@@ -451,7 +451,7 @@ STATIC const mp_arg_t pyb_spi_send_recv_args[] = {
}; };
#define PYB_SPI_SEND_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_recv_args) #define PYB_SPI_SEND_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_spi_send_recv_args)
STATIC mp_obj_t pyb_spi_send_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_spi_send_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO assumes transmission size is 8-bits wide // TODO assumes transmission size is 8-bits wide
pyb_spi_obj_t *self = args[0]; pyb_spi_obj_t *self = args[0];
......
...@@ -249,7 +249,7 @@ STATIC const mp_arg_t pyb_timer_init_args[] = { ...@@ -249,7 +249,7 @@ STATIC const mp_arg_t pyb_timer_init_args[] = {
}; };
#define PYB_TIMER_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_timer_init_args) #define PYB_TIMER_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_timer_init_args)
STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args // parse args
mp_arg_val_t vals[PYB_TIMER_INIT_NUM_ARGS]; mp_arg_val_t vals[PYB_TIMER_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PYB_TIMER_INIT_NUM_ARGS, pyb_timer_init_args, vals); mp_arg_parse_all(n_args, args, kw_args, PYB_TIMER_INIT_NUM_ARGS, pyb_timer_init_args, vals);
...@@ -331,7 +331,7 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, uint n_args, const ...@@ -331,7 +331,7 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, uint n_args, const
/// Construct a new timer object of the given id. If additional /// Construct a new timer object of the given id. If additional
/// arguments are given, then the timer is initialised by `init(...)`. /// arguments are given, then the timer is initialised by `init(...)`.
/// `id` can be 1 to 14, excluding 3. /// `id` can be 1 to 14, excluding 3.
STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
...@@ -377,7 +377,7 @@ STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con ...@@ -377,7 +377,7 @@ STATIC mp_obj_t pyb_timer_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
return (mp_obj_t)tim; return (mp_obj_t)tim;
} }
STATIC mp_obj_t pyb_timer_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_timer_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_timer_init_helper(args[0], n_args - 1, args + 1, kw_args); return pyb_timer_init_helper(args[0], n_args - 1, args + 1, kw_args);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
...@@ -400,7 +400,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit); ...@@ -400,7 +400,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
/// \method counter([value]) /// \method counter([value])
/// Get or set the timer counter. /// Get or set the timer counter.
mp_obj_t pyb_timer_counter(uint n_args, const mp_obj_t *args) { mp_obj_t pyb_timer_counter(mp_uint_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = args[0]; pyb_timer_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get // get
...@@ -415,7 +415,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_counter_obj, 1, 2, pyb_time ...@@ -415,7 +415,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_counter_obj, 1, 2, pyb_time
/// \method prescaler([value]) /// \method prescaler([value])
/// Get or set the prescaler for the timer. /// Get or set the prescaler for the timer.
mp_obj_t pyb_timer_prescaler(uint n_args, const mp_obj_t *args) { mp_obj_t pyb_timer_prescaler(mp_uint_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = args[0]; pyb_timer_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get // get
...@@ -430,7 +430,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_prescaler_obj, 1, 2, pyb_ti ...@@ -430,7 +430,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_prescaler_obj, 1, 2, pyb_ti
/// \method period([value]) /// \method period([value])
/// Get or set the period of the timer. /// Get or set the period of the timer.
mp_obj_t pyb_timer_period(uint n_args, const mp_obj_t *args) { mp_obj_t pyb_timer_period(mp_uint_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = args[0]; pyb_timer_obj_t *self = args[0];
if (n_args == 1) { if (n_args == 1) {
// get // get
......
...@@ -266,7 +266,7 @@ STATIC const mp_arg_t pyb_uart_init_args[] = { ...@@ -266,7 +266,7 @@ STATIC const mp_arg_t pyb_uart_init_args[] = {
}; };
#define PYB_UART_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_init_args) #define PYB_UART_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_init_args)
STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args // parse args
mp_arg_val_t vals[PYB_UART_INIT_NUM_ARGS]; mp_arg_val_t vals[PYB_UART_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PYB_UART_INIT_NUM_ARGS, pyb_uart_init_args, vals); mp_arg_parse_all(n_args, args, kw_args, PYB_UART_INIT_NUM_ARGS, pyb_uart_init_args, vals);
...@@ -313,7 +313,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp ...@@ -313,7 +313,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp
/// - `UART(6)` is on `YA`: `(TX, RX) = (Y1, Y2) = (PC6, PC7)` /// - `UART(6)` is on `YA`: `(TX, RX) = (Y1, Y2) = (PC6, PC7)`
/// - `UART(3)` is on `YB`: `(TX, RX) = (Y9, Y10) = (PB10, PB11)` /// - `UART(3)` is on `YB`: `(TX, RX) = (Y9, Y10) = (PB10, PB11)`
/// - `UART(2)` is on: `(TX, RX) = (X3, X4) = (PA2, PA3)` /// - `UART(2)` is on: `(TX, RX) = (X3, X4) = (PA2, PA3)`
STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
...@@ -353,7 +353,7 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, uint n_args, uint n_kw, cons ...@@ -353,7 +353,7 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, uint n_args, uint n_kw, cons
return o; return o;
} }
STATIC mp_obj_t pyb_uart_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_uart_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_uart_init_helper(args[0], n_args - 1, args + 1, kw_args); return pyb_uart_init_helper(args[0], n_args - 1, args + 1, kw_args);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init);
...@@ -392,7 +392,7 @@ STATIC const mp_arg_t pyb_uart_send_args[] = { ...@@ -392,7 +392,7 @@ STATIC const mp_arg_t pyb_uart_send_args[] = {
}; };
#define PYB_UART_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_send_args) #define PYB_UART_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_send_args)
STATIC mp_obj_t pyb_uart_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t pyb_uart_send(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {