Skip to content

Commit 55790a7

Browse files
AnnsAnnscrasbe
andcommitted
Apply suggestions from code review
Co-authored-by: crasbe <[email protected]>
1 parent 4c7b3e9 commit 55790a7

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

cpu/rp2350_common/include/periph_cpu.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@ extern "C" {
8787
void rp2350_init(void);
8888

8989
/**
90-
* @brief Calculate the address of the GPIO pad register for a given pin
91-
* @param pin The GPIO pin number
92-
* @return The address of the GPIO pad register for the given pin
90+
* @brief Calculate the address of the GPIO pad register for a given pin
91+
* @param[in] pin The GPIO pin number
92+
* @return The address of the GPIO pad register for the given pin
9393
*/
94-
static inline uint32_t* calculate_gpio_pad_register_addr(gpio_t pin) {
94+
static inline uint32_t* calculate_gpio_pad_register_addr(gpio_t pin)
95+
{
9596
/* Each pin has a 4 byte register, so we can calculate the address
96-
* by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
97-
* and adding 4 bytes to skip VOLTAGE_SELECT */
97+
* by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
98+
* and adding 4 bytes to skip VOLTAGE_SELECT */
9899
return (uint32_t*) (PADS_BANK0_BASE + (4 * (pin + 1)));
99100
}
100101

@@ -121,8 +122,6 @@ static inline uint32_t* calculate_gpio_io_ctrl_register_addr(gpio_t pin) {
121122
return (uint32_t*) (calculate_gpio_io_status_register_addr(pin) + 4);
122123
}
123124

124-
125-
126125
#ifdef __cplusplus
127126
}
128127
#endif

cpu/rp2350_common/periph/uart.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
# include "xh3irq.h"
2929
#endif
3030

31-
#include "board.h"
31+
#define ENABLE_DEBUG 0
32+
#include "debug.h"
3233

3334
static uart_isr_ctx_t ctx[UART_NUMOF];
3435

@@ -42,7 +43,6 @@ void _irq_enable(uart_t uart)
4243
{
4344
UART0_Type *dev = uart_config[uart].dev;
4445
/* We set the UART Receive Interrupt Mask (Bit 4) [See p979 UART 12.1]*/
45-
<<<<<<< HEAD
4646
dev->UARTIMSC = UART_UARTIMSC_RXIM_BITS;
4747
/* Enable the IRQ */
4848
rp_irq_enable(uart_config[uart].irqn);
@@ -70,19 +70,11 @@ void _set_symbolrate(uart_t uart, uint32_t baud)
7070

7171
dev->UARTIBRD = baud_ibrd;
7272
dev->UARTFBRD = baud_fbrd;
73-
=======
74-
dev->UARTIMSC = UART0_UARTIMSC_RXIM_Msk;
75-
/* Enable the IRQ in the NVIC */
76-
#ifdef RP2350_USE_RISCV
77-
xh3irq_enable_irq(uart_config[uart].irqn);
78-
#else
79-
NVIC_EnableIRQ(uart_config[uart].irqn);
80-
#endif
81-
>>>>>>> a64ab76543 (Apply suggestions from code review)
8273
}
8374

8475
int uart_mode(uart_t uart, uart_data_bits_t data_bits, uart_parity_t parity,
85-
uart_stop_bits_t stop_bits) {
76+
uart_stop_bits_t stop_bits)
77+
{
8678
assert((unsigned)uart < UART_NUMOF);
8779
UART0_Type *dev = uart_config[uart].dev;
8880

@@ -121,7 +113,8 @@ int uart_mode(uart_t uart, uart_data_bits_t data_bits, uart_parity_t parity,
121113
return UART_OK;
122114
}
123115

124-
static void _reset_uart(uart_t uart) {
116+
static void _reset_uart(uart_t uart)
117+
{
125118
switch (uart) {
126119
case 0:
127120
/* We reset UART0 here, so we can be sure it is in a known state */
@@ -136,7 +129,8 @@ static void _reset_uart(uart_t uart) {
136129
}
137130
}
138131

139-
void uart_init_pins(uart_t uart) {
132+
void uart_init_pins(uart_t uart)
133+
{
140134
assert((unsigned)uart < UART_NUMOF);
141135

142136
/* We reset UART0 here, so we can be sure it is in a known state */
@@ -211,9 +205,10 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
211205
}
212206
}
213207

214-
void uart_poweron(uart_t uart) {
208+
void uart_poweron(uart_t uart)
209+
{
215210
assert((unsigned)uart < UART_NUMOF);
216-
/* Get into a save state where we know what's up */
211+
/* Get into a safe state where we know what's up */
217212
_reset_uart(uart);
218213
UART0_Type *dev = uart_config[uart].dev;
219214
/* Restore config from registers */
@@ -228,7 +223,8 @@ void uart_poweron(uart_t uart) {
228223
uart_init_pins(uart);
229224
}
230225

231-
void uart_deinit_pins(uart_t uart) {
226+
void uart_deinit_pins(uart_t uart)
227+
{
232228
assert((unsigned)uart < UART_NUMOF);
233229
/* @TODO */
234230
/* gpio_reset_all_config(uart_config[uart].tx_pin); */
@@ -238,7 +234,8 @@ void uart_deinit_pins(uart_t uart) {
238234
}
239235
}
240236

241-
void uart_poweroff(uart_t uart) {
237+
void uart_poweroff(uart_t uart)
238+
{
242239
assert((unsigned)uart < UART_NUMOF);
243240
UART0_Type *dev = uart_config[uart].dev;
244241
/* backup configuration registers */
@@ -251,7 +248,8 @@ void uart_poweroff(uart_t uart) {
251248
_reset_uart(uart);
252249
}
253250

254-
void isr_handler(uint8_t num) {
251+
void isr_handler(uint8_t num)
252+
{
255253
UART0_Type *dev = uart_config[num].dev;
256254

257255
uint32_t status = dev->UARTMIS;
@@ -269,12 +267,14 @@ void isr_handler(uint8_t num) {
269267
}
270268

271269
/** Overwrites the WEAK_DEFAULT isr_uart0 */
272-
void isr_uart0(void) {
270+
void isr_uart0(void)
271+
{
273272
isr_handler(0);
274273
rp_end_isr();
275274
}
276275

277-
void isr_uart1(void) {
276+
void isr_uart1(void)
277+
{
278278
isr_handler(1);
279279
rp_end_isr();
280280
}

cpu/rp2350_common/vectors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ WEAK_DEFAULT void isr_spareirq_5(void);
9292
* @see 3.2 Interrupts and IRQn_Type in RP2350.h
9393
*/
9494
#ifdef RP2350_USE_ARM
95-
/* CortexM does some macro magic, RISCV does not */
95+
/* Cortex-M does some macro magic, RISC-V does not */
9696
ISR_VECTOR(1)
9797
#endif
9898
const void* vector_cpu[CPU_IRQ_NUMOF] = {

cpu/rp2350_riscv/cpu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
* @}
1616
*/
1717

18-
#include "board.h"
18+
#include <sys/unistd.h>
19+
1920
#include "cpu.h"
21+
#include "board.h"
2022
#include "clock_conf.h"
2123
#include "kernel_init.h"
22-
#include "periph/init.h"
23-
#include "periph/uart.h"
2424
#include "periph_conf.h"
2525

26-
#include <sys/unistd.h>
26+
#include "periph/init.h"
27+
#include "periph/uart.h"
2728

2829
/**
2930
* @brief Initialize the CPU, set IRQ priorities, clocks, peripheral

cpu/rp2350_riscv/include/core_cm33.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
extern "C" {
1111
#endif
1212

13-
#define __IM volatile const /*! Defines 'read only' structure member permissions */
14-
#define __OM volatile /*! Defines 'write only' structure member permissions */
15-
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
13+
#define __IM volatile const /**< Defines 'read only' structure member permissions */
14+
#define __OM volatile /**< Defines 'write only' structure member permissions */
15+
#define __IOM volatile /**< Defines 'read / write' structure member permissions */
1616

1717
#ifdef __cplusplus
1818
}

0 commit comments

Comments
 (0)