aboutsummaryrefslogtreecommitdiff
path: root/ports/minimal
diff options
context:
space:
mode:
authorDamien George2020-02-27 15:36:53 +1100
committerDamien George2020-02-28 10:33:03 +1100
commit69661f3343bedf86e514337cff63d96cc42f8859 (patch)
treeaf5dfb380ffdb75dda84828f63cf9d840d992f0f /ports/minimal
parent3f39d18c2b884d32f0443e2e8114ff9d7a14d718 (diff)
all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
Diffstat (limited to 'ports/minimal')
-rw-r--r--ports/minimal/frozentest.py8
-rw-r--r--ports/minimal/main.c20
-rw-r--r--ports/minimal/mpconfigport.h2
-rw-r--r--ports/minimal/mphalport.h7
-rw-r--r--ports/minimal/uart_core.c14
5 files changed, 29 insertions, 22 deletions
diff --git a/ports/minimal/frozentest.py b/ports/minimal/frozentest.py
index 0f99b7429..78cdd60bf 100644
--- a/ports/minimal/frozentest.py
+++ b/ports/minimal/frozentest.py
@@ -1,7 +1,7 @@
-print('uPy')
-print('a long string that is not interned')
-print('a string that has unicode αβγ chars')
-print(b'bytes 1234\x01')
+print("uPy")
+print("a long string that is not interned")
+print("a string that has unicode αβγ chars")
+print(b"bytes 1234\x01")
print(123456789)
for i in range(4):
print(i)
diff --git a/ports/minimal/main.c b/ports/minimal/main.c
index adc1dad0c..27ba9ed9f 100644
--- a/ports/minimal/main.c
+++ b/ports/minimal/main.c
@@ -33,7 +33,7 @@ static char heap[2048];
int main(int argc, char **argv) {
int stack_dummy;
- stack_top = (char*)&stack_dummy;
+ stack_top = (char *)&stack_dummy;
#if MICROPY_ENABLE_GC
gc_init(heap, heap + sizeof(heap));
@@ -84,11 +84,15 @@ mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
void nlr_jump_fail(void *val) {
- while (1);
+ while (1) {
+ ;
+ }
}
void NORETURN __fatal_error(const char *msg) {
- while (1);
+ while (1) {
+ ;
+ }
}
#ifndef NDEBUG
@@ -149,7 +153,7 @@ void _start(void) {
// when we get here: stack is initialised, bss is clear, data is copied
// SCB->CCR: enable 8-byte stack alignment for IRQ handlers, in accord with EABI
- *((volatile uint32_t*)0xe000ed14) |= 1 << 9;
+ *((volatile uint32_t *)0xe000ed14) |= 1 << 9;
// initialise the cpu and peripherals
#if MICROPY_MIN_USE_STM32_MCU
@@ -205,10 +209,10 @@ typedef struct {
volatile uint32_t CR1;
} periph_uart_t;
-#define USART1 ((periph_uart_t*) 0x40011000)
-#define GPIOA ((periph_gpio_t*) 0x40020000)
-#define GPIOB ((periph_gpio_t*) 0x40020400)
-#define RCC ((periph_rcc_t*) 0x40023800)
+#define USART1 ((periph_uart_t *) 0x40011000)
+#define GPIOA ((periph_gpio_t *) 0x40020000)
+#define GPIOB ((periph_gpio_t *) 0x40020400)
+#define RCC ((periph_rcc_t *) 0x40023800)
// simple GPIO interface
#define GPIO_MODE_IN (0)
diff --git a/ports/minimal/mpconfigport.h b/ports/minimal/mpconfigport.h
index f2a43523d..41e22cd01 100644
--- a/ports/minimal/mpconfigport.h
+++ b/ports/minimal/mpconfigport.h
@@ -60,7 +60,7 @@
// type definitions for the specific machine
-#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
+#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))
// This port is intended to be 32-bit, but unfortunately, int32_t for
// different targets may be defined in different ways - either as int
diff --git a/ports/minimal/mphalport.h b/ports/minimal/mphalport.h
index 60d68bd2d..5130d19a2 100644
--- a/ports/minimal/mphalport.h
+++ b/ports/minimal/mphalport.h
@@ -1,2 +1,5 @@
-static inline mp_uint_t mp_hal_ticks_ms(void) { return 0; }
-static inline void mp_hal_set_interrupt_char(char c) {}
+static inline mp_uint_t mp_hal_ticks_ms(void) {
+ return 0;
+}
+static inline void mp_hal_set_interrupt_char(char c) {
+}
diff --git a/ports/minimal/uart_core.c b/ports/minimal/uart_core.c
index d2d17b4d1..5b3797d2e 100644
--- a/ports/minimal/uart_core.c
+++ b/ports/minimal/uart_core.c
@@ -10,35 +10,35 @@ typedef struct {
volatile uint32_t SR;
volatile uint32_t DR;
} periph_uart_t;
-#define USART1 ((periph_uart_t*)0x40011000)
+#define USART1 ((periph_uart_t *)0x40011000)
#endif
// Receive single character
int mp_hal_stdin_rx_chr(void) {
unsigned char c = 0;
-#if MICROPY_MIN_USE_STDOUT
+ #if MICROPY_MIN_USE_STDOUT
int r = read(0, &c, 1);
(void)r;
-#elif MICROPY_MIN_USE_STM32_MCU
+ #elif MICROPY_MIN_USE_STM32_MCU
// wait for RXNE
while ((USART1->SR & (1 << 5)) == 0) {
}
c = USART1->DR;
-#endif
+ #endif
return c;
}
// Send string of given length
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
-#if MICROPY_MIN_USE_STDOUT
+ #if MICROPY_MIN_USE_STDOUT
int r = write(1, str, len);
(void)r;
-#elif MICROPY_MIN_USE_STM32_MCU
+ #elif MICROPY_MIN_USE_STM32_MCU
while (len--) {
// wait for TXE
while ((USART1->SR & (1 << 7)) == 0) {
}
USART1->DR = *str++;
}
-#endif
+ #endif
}