Skip to content

Commit

Permalink
Rename rp2350 function uart_first/uart_second -> uart/uart_secondary …
Browse files Browse the repository at this point in the history
…for consistency with rp2040
  • Loading branch information
Grazfather committed Mar 7, 2025
1 parent 0f4e33e commit db869de
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 70 deletions.
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/adc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const rp2xxx = microzig.hal;
const gpio = rp2xxx.gpio;
const adc = rp2xxx.adc;
const time = rp2xxx.time;
const chip = rp2xxx.compatibility.chip;

const uart = rp2xxx.uart.instance.num(0);
const baud_rate = 115200;
Expand All @@ -22,13 +21,8 @@ pub fn main() void {
.temp_sensor_enabled = true,
});

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/flash_id.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const rp2xxx = microzig.hal;
const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const flash = rp2xxx.flash;
const chip = rp2xxx.compatibility.chip;

const uart = rp2xxx.uart.instance.num(0);
const baud_rate = 115200;
Expand All @@ -24,13 +23,8 @@ pub const std_options = struct {
};

pub fn main() !void {
switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/flash_program.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const flash = rp2xxx.flash;
const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const clocks = rp2xxx.clocks;
const chip = rp2xxx.compatibility.chip;

const led = gpio.num(25);
const uart = rp2xxx.uart.instance.num(0);
Expand All @@ -33,13 +32,8 @@ pub fn main() !void {
led.set_direction(.out);
led.put(1);

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
9 changes: 2 additions & 7 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/i2c_bus_scan.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ const uart_rx_pin = gpio.num(1);
const i2c0 = i2c.instance.num(0);

pub fn main() !void {
switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/random.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const clocks = rp2xxx.clocks;
const rand = rp2xxx.rand;
const chip = rp2xxx.compatibility.chip;

const led = gpio.num(25);
const uart = rp2xxx.uart.instance.num(0);
Expand All @@ -33,13 +32,8 @@ pub fn main() !void {
led.set_direction(.out);
led.put(1);

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/uart_log.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const rp2xxx = microzig.hal;
const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const clocks = rp2xxx.clocks;
const chip = rp2xxx.compatibility.chip;

const led = gpio.num(25);
const uart = rp2xxx.uart.instance.num(0);
Expand All @@ -29,13 +28,8 @@ pub fn main() !void {
led.set_direction(.out);
led.put(1);

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/rp2040_only/usb_hid.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const clocks = rp2xxx.clocks;
const usb = rp2xxx.usb;
const chip = rp2xxx.compatibility.chip;

const led = gpio.num(25);
const uart = rp2xxx.uart.instance.num(0);
Expand Down Expand Up @@ -71,13 +70,8 @@ pub fn main() !void {
led.set_direction(.out);
led.put(1);

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
5 changes: 1 addition & 4 deletions examples/raspberrypi/rp2xxx/src/spi_slave.zig
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ pub fn main() !void {
pin.set_function(.spi);
}

switch (chip) {
.RP2040 => uart_tx_pin.set_function(.uart),
.RP2350 => uart_tx_pin.set_function(.uart_first),
}
uart_tx_pin.set_function(.uart);
uart.apply(.{
.baud_rate = uart_baud_rate,
.clock_config = rp2xxx.clock_config,
Expand Down
10 changes: 2 additions & 8 deletions examples/raspberrypi/rp2xxx/src/usb_cdc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const clocks = rp2xxx.clocks;
const usb = rp2xxx.usb;
const chip = rp2xxx.compatibility.chip;

const led = gpio.num(25);
const uart = rp2xxx.uart.instance.num(0);
Expand Down Expand Up @@ -69,13 +68,8 @@ pub fn main() !void {
led.set_direction(.out);
led.put(1);

switch (chip) {
.RP2040 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
},
.RP2350 => inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart_second);
},
inline for (&.{ uart_tx_pin, uart_rx_pin }) |pin| {
pin.set_function(.uart);
}

uart.apply(.{
Expand Down
5 changes: 2 additions & 3 deletions port/raspberrypi/rp2xxx/src/hal/gpio.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub const Function =
.RP2350 => enum(u5) {
hstx = 0,
spi,
// TODO: Not in love with this naming
uart_first,
uart,
i2c,
pwm,
sio,
Expand All @@ -41,7 +40,7 @@ pub const Function =
pio2,
gpck,
usb,
uart_second,
uart_secondary,
disabled = 0x1f,
},
};
Expand Down

0 comments on commit db869de

Please sign in to comment.