Skip to content

Commit a1268cc

Browse files
committed
Update mcumap_rp2350.h
1 parent 0b63222 commit a1268cc

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

uCNC/src/hal/mcus/rp2350/mcumap_rp2350.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ extern "C"
7575
#define MCU_CYCLES_LOOP_OVERHEAD 1
7676
#endif
7777

78-
#define mcu_delay_loop(X) \
79-
do \
80-
{ \
78+
#define mcu_delay_loop(X) \
79+
do \
80+
{ \
8181
asm volatile("" ::: "memory"); \
8282
register uint16_t __count = (X); \
8383
__asm__ volatile( \
84-
"1: sub %[cnt], %[cnt], #1\n" /* 1 cycle */ \
85-
" cmp %[cnt], #0\n" /* 1 cycle */ \
86-
" bne 1b\n" /* 1–2 cycles */ \
87-
" nop\n" /* 1 cycle */ \
88-
: [cnt] "+r"(__count) \
89-
: \
90-
: "cc"); \
84+
"1: sub %[cnt], %[cnt], #1\n" /* 1 cycle */ \
85+
" cmp %[cnt], #0\n" /* 1 cycle */ \
86+
" bne 1b\n" /* 1–2 cycles */ \
87+
" nop\n" /* 1 cycle */ \
88+
: [cnt] "+r"(__count) \
89+
: \
90+
: "cc"); \
9191
asm volatile("" ::: "memory"); \
9292
} while (0)
9393

@@ -1361,20 +1361,20 @@ extern "C"
13611361

13621362
#ifndef BYTE_OPS
13631363
#define BYTE_OPS
1364-
#define SETBIT(x, y) ((x) |= (1UL << (y))) /* Set bit y in byte x*/
1364+
#define SETBIT(x, y) ((x) |= (1UL << (y))) /* Set bit y in byte x*/
13651365
#define CLEARBIT(x, y) ((x) &= ~(1UL << (y))) /* Clear bit y in byte x*/
1366-
#define CHECKBIT(x, y) ((x) & (1UL << (y))) /* Check bit y in byte x*/
1366+
#define CHECKBIT(x, y) ((x) & (1UL << (y))) /* Check bit y in byte x*/
13671367
#define TOGGLEBIT(x, y) ((x) ^= (1UL << (y))) /* Toggle bit y in byte x*/
13681368

1369-
#define SETFLAG(x, y) ((x) |= (y)) /* Set byte y in byte x*/
1369+
#define SETFLAG(x, y) ((x) |= (y)) /* Set byte y in byte x*/
13701370
#define CLEARFLAG(x, y) ((x) &= ~(y)) /* Clear byte y in byte x*/
1371-
#define CHECKFLAG(x, y) ((x) & (y)) /* Check byte y in byte x*/
1371+
#define CHECKFLAG(x, y) ((x) & (y)) /* Check byte y in byte x*/
13721372
#define TOGGLEFLAG(x, y) ((x) ^= (y)) /* Toggle byte y in byte x*/
13731373
#endif
13741374

13751375
#define mcu_config_output(X) pinMode(__indirect__(X, BIT), OUTPUT)
1376-
#define mcu_config_pwm(X, freq) \
1377-
{ \
1376+
#define mcu_config_pwm(X, freq) \
1377+
{ \
13781378
pinMode(__indirect__(X, BIT), OUTPUT); \
13791379
analogWriteRange(255); \
13801380
analogWriteFreq(freq); \
@@ -1392,8 +1392,8 @@ extern "C"
13921392
#define mcu_toggle_output(X) ({ sio_hw->gpio_togl = (1UL << __indirect__(X, BIT)); })
13931393

13941394
extern uint8_t rp2350_pwm[16];
1395-
#define mcu_set_pwm(X, Y) \
1396-
{ \
1395+
#define mcu_set_pwm(X, Y) \
1396+
{ \
13971397
rp2350_pwm[X - PWM_PINS_OFFSET] = Y; \
13981398
analogWrite(__indirect__(X, BIT), Y); \
13991399
}
@@ -1402,7 +1402,7 @@ extern "C"
14021402

14031403
#define mcu_millis() to_ms_since_boot(get_absolute_time())
14041404
#define mcu_micros() to_us_since_boot(get_absolute_time())
1405-
#define mcu_free_micros() ((uint32_t)((((SysTick->LOAD + 1) - SysTick->VAL) * 1000UL) / (SysTick->LOAD + 1)))
1405+
#define mcu_free_micros() (mcu_micros() % 1000)
14061406

14071407
#include "cmsis_gcc.h"
14081408
#define mcu_enable_global_isr __enable_irq
@@ -1419,39 +1419,39 @@ extern "C"
14191419
#define USE_CUSTOM_BUFFER_IMPLEMENTATION
14201420
#include <pico/util/queue.h>
14211421
#define DECL_BUFFER(type, name, size) \
1422-
static queue_t name##_bufferdata; \
1422+
static queue_t name##_bufferdata; \
14231423
ring_buffer_t name = {0, 0, 0, (uint8_t *)&name##_bufferdata, size, sizeof(type)}
14241424
#define BUFFER_INIT(type, name, size) \
1425-
extern ring_buffer_t name; \
1425+
extern ring_buffer_t name; \
14261426
queue_init((queue_t *)name.data, sizeof(type), size)
14271427
#define BUFFER_WRITE_AVAILABLE(buffer) (buffer.size - queue_get_level((queue_t *)buffer.data))
14281428
#define BUFFER_READ_AVAILABLE(buffer) (queue_get_level((queue_t *)buffer.data))
14291429
#define BUFFER_EMPTY(buffer) queue_is_empty((queue_t *)buffer.data)
14301430
#define BUFFER_FULL(buffer) queue_is_full((queue_t *)buffer.data)
1431-
#define BUFFER_PEEK(buffer, ptr) \
1431+
#define BUFFER_PEEK(buffer, ptr) \
14321432
if (!queue_try_peek((queue_t *)buffer.data, ptr)) \
14331433
{ \
1434-
memset(ptr, 0, buffer.elem_size); \
1434+
memset(ptr, 0, buffer.elem_size); \
14351435
}
1436-
#define BUFFER_TRY_DEQUEUE(buffer, ptr) \
1436+
#define BUFFER_TRY_DEQUEUE(buffer, ptr) \
14371437
if (!queue_try_remove((queue_t *)buffer.data, ptr)) \
14381438
{ \
1439-
memset(ptr, 0, buffer.elem_size); \
1439+
memset(ptr, 0, buffer.elem_size); \
14401440
}
14411441
#define BUFFER_DEQUEUE(buffer, ptr) \
1442-
do \
1443-
{ \
1442+
do \
1443+
{ \
14441444
} while (!queue_try_remove((queue_t *)buffer.data, ptr))
14451445
#define BUFFER_TRY_ENQUEUE(buffer, ptr) queue_try_add((queue_t *)buffer.data, ptr)
14461446
#define BUFFER_ENQUEUE(buffer, ptr) \
1447-
do \
1448-
{ \
1447+
do \
1448+
{ \
14491449
} while (!queue_try_add((queue_t *)buffer.data, ptr))
14501450
#define BUFFER_WRITE(buffer, ptr, len, written) ({for(uint8_t i = 0; i<len; i++){if(!queue_try_add((queue_t*)buffer.data, &ptr[i])){break;}written++;} })
14511451
#define BUFFER_READ(buffer, ptr, len, read) ({for(uint8_t i = 0; i<len; i++){if(!queue_try_remove((queue_t*)buffer.data, &ptr[i])){break;}read++;} })
1452-
#define BUFFER_CLEAR(buffer) \
1453-
while (!queue_is_empty((queue_t *)buffer.data)) \
1454-
{ \
1452+
#define BUFFER_CLEAR(buffer) \
1453+
while (!queue_is_empty((queue_t *)buffer.data)) \
1454+
{ \
14551455
queue_try_remove((queue_t *)buffer.data, NULL); \
14561456
}
14571457

0 commit comments

Comments
 (0)