mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user