Skip to content

Commit dfa7c3d

Browse files
committed
codeformat: Fix handling of **
After discussing with danh, I noticed that `a/**/b` would not match `a/b`. After correcting this and re-running "pre-commit run --all", additional files were reindented, including the codeformat script itself.
1 parent e95e921 commit dfa7c3d

File tree

22 files changed

+433
-429
lines changed

22 files changed

+433
-429
lines changed

mpy-cross/main.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ STATIC int compile_and_save(const char *file, const char *output_file, const cha
7676

7777
STATIC int usage(char **argv) {
7878
printf(
79-
"usage: %s [<opts>] [-X <implopt>] <input filename>\n"
80-
"Options:\n"
81-
"--version : show version information\n"
82-
"-o : output file for compiled bytecode (defaults to input with .mpy extension)\n"
83-
"-s : source filename to embed in the compiled bytecode (defaults to input file)\n"
84-
"-v : verbose (trace various operations); can be multiple\n"
85-
"-O[N] : apply bytecode optimizations of level N\n"
86-
"\n"
87-
"Target specific options:\n"
88-
"-msmall-int-bits=number : set the maximum bits used to encode a small-int\n"
89-
"-mno-unicode : don't support unicode in compiled strings\n"
90-
"-mcache-lookup-bc : cache map lookups in the bytecode\n"
91-
"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, xtensa\n"
92-
"\n"
93-
"Implementation specific options:\n", argv[0]
94-
);
79+
"usage: %s [<opts>] [-X <implopt>] <input filename>\n"
80+
"Options:\n"
81+
"--version : show version information\n"
82+
"-o : output file for compiled bytecode (defaults to input with .mpy extension)\n"
83+
"-s : source filename to embed in the compiled bytecode (defaults to input file)\n"
84+
"-v : verbose (trace various operations); can be multiple\n"
85+
"-O[N] : apply bytecode optimizations of level N\n"
86+
"\n"
87+
"Target specific options:\n"
88+
"-msmall-int-bits=number : set the maximum bits used to encode a small-int\n"
89+
"-mno-unicode : don't support unicode in compiled strings\n"
90+
"-mcache-lookup-bc : cache map lookups in the bytecode\n"
91+
"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, xtensa\n"
92+
"\n"
93+
"Implementation specific options:\n", argv[0]
94+
);
9595
int impl_opts_cnt = 0;
9696
printf(
9797
" emit={bytecode,native,viper} -- set the default code emitter\n"

ports/atmel-samd/boards/cp_sapling_m0_revb/mpconfigboard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#define MICROPY_PORT_B (0)
88
#define MICROPY_PORT_C (0)
99

10-
#define IGNORE_PIN_PA04 1
11-
#define IGNORE_PIN_PA05 1
12-
#define IGNORE_PIN_PA06 1
10+
#define IGNORE_PIN_PA04 1
11+
#define IGNORE_PIN_PA05 1
12+
#define IGNORE_PIN_PA06 1
1313
#define IGNORE_PIN_PA12 1
1414
#define IGNORE_PIN_PA13 1
1515
#define IGNORE_PIN_PA20 1

ports/atmel-samd/common-hal/busio/I2C.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct {
4141
uint8_t sda_pin;
4242
} busio_i2c_obj_t;
4343

44-
extern Sercom *samd_i2c_get_sercom(const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda,
45-
uint8_t *sercom_index, uint32_t *sda_pinmux, uint32_t *scl_pinmux);
44+
extern Sercom *samd_i2c_get_sercom(const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda,
45+
uint8_t *sercom_index, uint32_t *sda_pinmux, uint32_t *scl_pinmux);
4646

4747
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_H

ports/atmel-samd/common-hal/busio/UART.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ static void usart_async_rxc_callback(const struct usart_async_descriptor *const
5555
}
5656

5757
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
58-
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
59-
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
60-
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
58+
const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx,
59+
const mcu_pin_obj_t *rts, const mcu_pin_obj_t *cts,
60+
const mcu_pin_obj_t *rs485_dir, bool rs485_invert,
6161
uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
62-
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
62+
mp_float_t timeout, uint16_t receiver_buffer_size, byte *receiver_buffer,
6363
bool sigint_enabled) {
6464

65-
Sercom* sercom = NULL;
65+
Sercom *sercom = NULL;
6666
uint8_t sercom_index = 255; // Unset index
6767
uint32_t rx_pinmux = 0;
6868
uint8_t rx_pad = 255; // Unset pad
@@ -88,29 +88,29 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
8888
self->timeout_ms = timeout * 1000;
8989

9090
// This assignment is only here because the usart_async routines take a *const argument.
91-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
91+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
9292

9393
for (int i = 0; i < NUM_SERCOMS_PER_PIN; i++) {
94-
Sercom* potential_sercom = NULL;
94+
Sercom *potential_sercom = NULL;
9595
if (have_tx) {
9696
sercom_index = tx->sercom[i].index;
9797
if (sercom_index >= SERCOM_INST_NUM) {
9898
continue;
9999
}
100100
potential_sercom = sercom_insts[sercom_index];
101-
#ifdef SAMD21
102-
if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
101+
#ifdef SAMD21
102+
if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
103103
!(tx->sercom[i].pad == 0 ||
104104
tx->sercom[i].pad == 2)) {
105105
continue;
106106
}
107-
#endif
108-
#ifdef SAM_D5X_E5X
109-
if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
107+
#endif
108+
#ifdef SAM_D5X_E5X
109+
if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
110110
!(tx->sercom[i].pad == 0)) {
111111
continue;
112112
}
113-
#endif
113+
#endif
114114
tx_pinmux = PINMUX(tx->number, (i == 0) ? MUX_C : MUX_D);
115115
tx_pad = tx->sercom[i].pad;
116116
if (rx == NULL) {
@@ -158,7 +158,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
158158
// self->buffer, so do it manually. (However, as long as internal
159159
// pointers like this are NOT moved, allocating the buffer
160160
// in the long-lived pool is not strictly necessary)
161-
self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, true);
161+
self->buffer = (uint8_t *)gc_alloc(self->buffer_length * sizeof(uint8_t), false, true);
162162
if (self->buffer == NULL) {
163163
common_hal_busio_uart_deinit(self);
164164
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t));
@@ -191,24 +191,24 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
191191
// Doing a group mask and set of the registers saves 60 bytes over setting the bitfields individually.
192192

193193
sercom->USART.CTRLA.reg &= ~(SERCOM_USART_CTRLA_TXPO_Msk |
194-
SERCOM_USART_CTRLA_RXPO_Msk |
195-
SERCOM_USART_CTRLA_FORM_Msk);
194+
SERCOM_USART_CTRLA_RXPO_Msk |
195+
SERCOM_USART_CTRLA_FORM_Msk);
196196
sercom->USART.CTRLA.reg |= SERCOM_USART_CTRLA_TXPO(tx_pad / 2) |
197-
SERCOM_USART_CTRLA_RXPO(rx_pad) |
198-
(parity == BUSIO_UART_PARITY_NONE ? 0 : SERCOM_USART_CTRLA_FORM(1));
197+
SERCOM_USART_CTRLA_RXPO(rx_pad) |
198+
(parity == BUSIO_UART_PARITY_NONE ? 0 : SERCOM_USART_CTRLA_FORM(1));
199199

200200
// Enable tx and/or rx based on whether the pins were specified.
201201
// CHSIZE is 0 for 8 bits, 5, 6, 7 for 5, 6, 7 bits. 1 for 9 bits, but we don't support that.
202202
sercom->USART.CTRLB.reg &= ~(SERCOM_USART_CTRLB_TXEN |
203-
SERCOM_USART_CTRLB_RXEN |
204-
SERCOM_USART_CTRLB_PMODE |
205-
SERCOM_USART_CTRLB_SBMODE |
206-
SERCOM_USART_CTRLB_CHSIZE_Msk);
203+
SERCOM_USART_CTRLB_RXEN |
204+
SERCOM_USART_CTRLB_PMODE |
205+
SERCOM_USART_CTRLB_SBMODE |
206+
SERCOM_USART_CTRLB_CHSIZE_Msk);
207207
sercom->USART.CTRLB.reg |= (have_tx ? SERCOM_USART_CTRLB_TXEN : 0) |
208-
(have_rx ? SERCOM_USART_CTRLB_RXEN : 0) |
209-
(parity == BUSIO_UART_PARITY_ODD ? SERCOM_USART_CTRLB_PMODE : 0) |
210-
(stop > 1 ? SERCOM_USART_CTRLB_SBMODE : 0) |
211-
SERCOM_USART_CTRLB_CHSIZE(bits % 8);
208+
(have_rx ? SERCOM_USART_CTRLB_RXEN : 0) |
209+
(parity == BUSIO_UART_PARITY_ODD ? SERCOM_USART_CTRLB_PMODE : 0) |
210+
(stop > 1 ? SERCOM_USART_CTRLB_SBMODE : 0) |
211+
SERCOM_USART_CTRLB_CHSIZE(bits % 8);
212212

213213
// Set baud rate
214214
common_hal_busio_uart_set_baudrate(self, baudrate);
@@ -227,7 +227,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
227227
gpio_set_pin_direction(tx->number, GPIO_DIRECTION_OUT);
228228
gpio_set_pin_pull_mode(tx->number, GPIO_PULL_OFF);
229229
gpio_set_pin_function(tx->number, tx_pinmux);
230-
self->tx_pin = tx->number;
230+
self->tx_pin = tx->number;
231231
claim_pin(tx);
232232
} else {
233233
self->tx_pin = NO_PIN;
@@ -237,7 +237,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
237237
gpio_set_pin_direction(rx->number, GPIO_DIRECTION_IN);
238238
gpio_set_pin_pull_mode(rx->number, GPIO_PULL_OFF);
239239
gpio_set_pin_function(rx->number, rx_pinmux);
240-
self->rx_pin = rx->number;
240+
self->rx_pin = rx->number;
241241
claim_pin(rx);
242242
} else {
243243
self->rx_pin = NO_PIN;
@@ -255,7 +255,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
255255
return;
256256
}
257257
// This assignment is only here because the usart_async routines take a *const argument.
258-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
258+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
259259
usart_async_disable(usart_desc_p);
260260
usart_async_deinit(usart_desc_p);
261261
reset_pin_number(self->rx_pin);
@@ -271,7 +271,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
271271
}
272272

273273
// This assignment is only here because the usart_async routines take a *const argument.
274-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
274+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
275275

276276
if (len == 0) {
277277
// Nothing to read.
@@ -328,7 +328,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
328328
}
329329

330330
// This assignment is only here because the usart_async routines take a *const argument.
331-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
331+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
332332

333333
struct io_descriptor *io;
334334
usart_async_get_io_descriptor(usart_desc_p, &io);
@@ -359,21 +359,21 @@ uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
359359

360360
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
361361
// This assignment is only here because the usart_async routines take a *const argument.
362-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
362+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
363363
usart_async_set_baud_rate(usart_desc_p,
364-
// Samples and ARITHMETIC vs FRACTIONAL must correspond to USART_SAMPR in
365-
// hpl_sercom_config.h.
366-
_usart_async_calculate_baud_rate(baudrate, // e.g. 9600 baud
367-
PROTOTYPE_SERCOM_USART_ASYNC_CLOCK_FREQUENCY,
368-
16, // samples
369-
USART_BAUDRATE_ASYNCH_ARITHMETIC,
370-
0 // fraction - not used for ARITHMETIC
371-
));
364+
// Samples and ARITHMETIC vs FRACTIONAL must correspond to USART_SAMPR in
365+
// hpl_sercom_config.h.
366+
_usart_async_calculate_baud_rate(baudrate, // e.g. 9600 baud
367+
PROTOTYPE_SERCOM_USART_ASYNC_CLOCK_FREQUENCY,
368+
16, // samples
369+
USART_BAUDRATE_ASYNCH_ARITHMETIC,
370+
0 // fraction - not used for ARITHMETIC
371+
));
372372
self->baudrate = baudrate;
373373
}
374374

375375
mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) {
376-
return (mp_float_t) (self->timeout_ms / 1000.0f);
376+
return (mp_float_t)(self->timeout_ms / 1000.0f);
377377
}
378378

379379
void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) {
@@ -382,15 +382,15 @@ void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeou
382382

383383
uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
384384
// This assignment is only here because the usart_async routines take a *const argument.
385-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
385+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
386386
struct usart_async_status async_status;
387387
usart_async_get_status(usart_desc_p, &async_status);
388388
return async_status.rxcnt;
389389
}
390390

391391
void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) {
392392
// This assignment is only here because the usart_async routines take a *const argument.
393-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
393+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
394394
usart_async_flush_rx_buffer(usart_desc_p);
395395

396396
}
@@ -401,7 +401,7 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
401401
return false;
402402
}
403403
// This assignment is only here because the usart_async routines take a *const argument.
404-
struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc;
404+
struct usart_async_descriptor *const usart_desc_p = (struct usart_async_descriptor *const)&self->usart_desc;
405405
struct usart_async_status async_status;
406406
usart_async_get_status(usart_desc_p, &async_status);
407407
return !(async_status.flags & USART_ASYNC_STATUS_BUSY);

ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include "peripherals/samd/sercom.h"
3737

3838
void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_peripheral_obj_t *self,
39-
const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda,
40-
uint8_t *addresses, unsigned int num_addresses, bool smbus) {
39+
const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda,
40+
uint8_t *addresses, unsigned int num_addresses, bool smbus) {
4141
uint8_t sercom_index;
4242
uint32_t sda_pinmux, scl_pinmux;
4343
Sercom *sercom = samd_i2c_get_sercom(scl, sda, &sercom_index, &sda_pinmux, &scl_pinmux);
@@ -58,12 +58,13 @@ void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_periphe
5858

5959
samd_peripherals_sercom_clock_init(sercom, sercom_index);
6060

61-
#ifdef SAM_D5X_E5X
61+
#ifdef SAM_D5X_E5X
6262
sercom->I2CS.CTRLC.bit.SDASETUP = 0x08;
63-
#endif
63+
#endif
6464

6565
sercom->I2CS.CTRLA.bit.SWRST = 1;
66-
while (sercom->I2CS.CTRLA.bit.SWRST || sercom->I2CS.SYNCBUSY.bit.SWRST) {}
66+
while (sercom->I2CS.CTRLA.bit.SWRST || sercom->I2CS.SYNCBUSY.bit.SWRST) {
67+
}
6768

6869
sercom->I2CS.CTRLB.bit.AACKEN = 0; // Automatic acknowledge is disabled.
6970

@@ -134,8 +135,7 @@ static int i2c_peripheral_check_error(i2cperipheral_i2c_peripheral_obj_t *self,
134135
return -err;
135136
}
136137

137-
int common_hal_i2cperipheral_i2c_peripheral_is_addressed(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t *address, bool *is_read, bool *is_restart)
138-
{
138+
int common_hal_i2cperipheral_i2c_peripheral_is_addressed(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t *address, bool *is_read, bool *is_restart) {
139139
int err = i2c_peripheral_check_error(self, false);
140140
if (err) {
141141
return err;

ports/atmel-samd/common-hal/microcontroller/Pin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void reset_all_pins(void);
4444
// need to store a full pointer.
4545
void reset_pin_number(uint8_t pin_number);
4646
void never_reset_pin_number(uint8_t pin_number);
47-
void claim_pin(const mcu_pin_obj_t* pin);
47+
void claim_pin(const mcu_pin_obj_t *pin);
4848
bool pin_number_is_free(uint8_t pin_number);
4949

5050
typedef struct {

0 commit comments

Comments
 (0)