aboutsummaryrefslogtreecommitdiff
path: root/ports/teensy/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/teensy/main.c')
-rw-r--r--ports/teensy/main.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/ports/teensy/main.c b/ports/teensy/main.c
index 021ca546c..142f71006 100644
--- a/ports/teensy/main.c
+++ b/ports/teensy/main.c
@@ -93,7 +93,7 @@ mp_obj_t pyb_analog_write_frequency(mp_obj_t pin_obj, mp_obj_t freq_obj) {
static mp_obj_t pyb_info(void) {
// get and print unique id; 96 bits
{
- byte *id = (byte*)0x40048058;
+ byte *id = (byte *)0x40048058;
printf("ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x\n", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7], id[8], id[9], id[10], id[11]);
}
@@ -121,7 +121,7 @@ static mp_obj_t pyb_info(void) {
printf(" 1=%u 2=%u m=%u\n", info.num_1block, info.num_2block, info.max_block);
}
-#if 0
+ #if 0
// free space on flash
{
DWORD nclst;
@@ -129,7 +129,7 @@ static mp_obj_t pyb_info(void) {
f_getfree("0:", &nclst, &fatfs);
printf("LFS free: %u bytes\n", (uint)(nclst * fatfs->csize * 512));
}
-#endif
+ #endif
return mp_const_none;
}
@@ -162,7 +162,7 @@ mp_obj_t pyb_gpio(int n_args, mp_obj_t *args) {
pinMode(pin, INPUT);
return MP_OBJ_NEW_SMALL_INT(digitalRead(pin));
}
-
+
// set pin
pinMode(pin, OUTPUT);
digitalWrite(pin, mp_obj_is_true(args[1]));
@@ -264,7 +264,7 @@ soft_reset:
led_state(PYB_LED_BUILTIN, 1);
// GC init
- gc_init(&_heap_start, (void*)HEAP_END);
+ gc_init(&_heap_start, (void *)HEAP_END);
// MicroPython init
mp_init();
@@ -276,7 +276,7 @@ soft_reset:
pin_init0();
-#if 0
+ #if 0
// add some functions to the python namespace
{
mp_store_name(MP_QSTR_help, mp_make_function_n(0, pyb_help));
@@ -297,23 +297,23 @@ soft_reset:
mp_store_attr(m, MP_QSTR_Servo, mp_make_function_n(0, pyb_Servo));
mp_store_name(MP_QSTR_pyb, m);
}
-#endif
+ #endif
-#if MICROPY_MODULE_FROZEN
+ #if MICROPY_MODULE_FROZEN
pyexec_frozen_module("boot.py");
-#else
+ #else
if (!pyexec_file_if_exists("/boot.py")) {
flash_error(4);
}
-#endif
+ #endif
// Turn bootup LED off
led_state(PYB_LED_BUILTIN, 0);
// run main script
-#if MICROPY_MODULE_FROZEN
+ #if MICROPY_MODULE_FROZEN
pyexec_frozen_module("main.py");
-#else
+ #else
{
vstr_t *vstr = vstr_new(16);
vstr_add_str(vstr, "/");
@@ -327,7 +327,7 @@ soft_reset:
}
vstr_free(vstr);
}
-#endif
+ #endif
// enter REPL
// REPL mode can change, or it can request a soft reset
@@ -358,24 +358,25 @@ void __libc_init_array(void) {
// ultoa is used by usb_init_serialnumber. Normally ultoa would be provided
// by nonstd.c from the teensy core, but it conflicts with some of the
// MicroPython functions in string0.c, so we provide ultoa here.
-char * ultoa(unsigned long val, char *buf, int radix)
-{
- unsigned digit;
- int i=0, j;
- char t;
-
- while (1) {
- digit = val % radix;
- buf[i] = ((digit < 10) ? '0' + digit : 'A' + digit - 10);
- val /= radix;
- if (val == 0) break;
- i++;
- }
- buf[i + 1] = 0;
- for (j=0; j < i; j++, i--) {
- t = buf[j];
- buf[j] = buf[i];
- buf[i] = t;
- }
- return buf;
+char *ultoa(unsigned long val, char *buf, int radix) {
+ unsigned digit;
+ int i = 0, j;
+ char t;
+
+ while (1) {
+ digit = val % radix;
+ buf[i] = ((digit < 10) ? '0' + digit : 'A' + digit - 10);
+ val /= radix;
+ if (val == 0) {
+ break;
+ }
+ i++;
+ }
+ buf[i + 1] = 0;
+ for (j = 0; j < i; j++, i--) {
+ t = buf[j];
+ buf[j] = buf[i];
+ buf[i] = t;
+ }
+ return buf;
}