1// Copyright © 2021 Sören Tempel2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU Affero General Public License as5// published by the Free Software Foundation, either version 3 of the6// License, or (at your option) any later version.7//8// This program is distributed in the hope that it will be useful, but9// WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11// Affero General Public License for more details.12//13// You should have received a copy of the GNU Affero General Public License14// along with this program. If not, see <https://www.gnu.org/licenses/>.1516const gpio = @import("gpio.zig");17const plic = @import("plic.zig");18const uart = @import("uart.zig");19const smux = @import("slipmux.zig");2021// Addresses of FE310 peripherals.22const UART0_CTRL_ADDR: usize = 0x10013000;23const UART1_CTRL_ADDR: usize = 0x10023000;24const PLIC_CTRL_ADDR: usize = 0x0C000000;25const GPIO_CTRL_ADDR: usize = 0x10012000;2627// LEDs.28pub const led0 = gpio.pin(0, 22);29pub const led1 = gpio.pin(0, 19);30pub const led2 = gpio.pin(0, 21);3132pub const gpio0 = gpio.Gpio{33 .base_addr = GPIO_CTRL_ADDR,34};35pub const plic0 = plic.Plic{36 .base_addr = PLIC_CTRL_ADDR,37};3839const uart0 = uart.Uart{40 .base_addr = UART0_CTRL_ADDR,41 .rx_pin = gpio.pin(0, 16),42 .tx_pin = gpio.pin(0, 17),43 .irq = 3,44};45var slip0 = smux.Slip{46 .uart = &uart0,47 .plic = &plic0,48};49pub var slipmux = smux.SlipMux{50 .slip = &slip0,51};5253pub fn init() void {54 plic0.init();55 uart0.init(gpio0, .{ .tx = true, .rx = true });5657 gpio0.init(led0, gpio.Mode.OUT);58 gpio0.init(led1, gpio.Mode.OUT);59 gpio0.init(led2, gpio.Mode.OUT);6061 gpio0.set(led0, 1);62 gpio0.set(led1, 1);63 gpio0.set(led2, 1);64}