Add hardware memory map

This commit is contained in:
Victor Mignot 2024-08-24 20:19:11 +02:00
parent 5f62d443dc
commit ab2df6d8ca
Signed by: dala
GPG key ID: 5E7F2CE1BEAFED3D
2 changed files with 293 additions and 0 deletions

292
src/devices.rs Normal file
View file

@ -0,0 +1,292 @@
const DEVICE_NB: usize = 42;
pub enum Device {
Pmu,
Radio,
Uart,
Spi,
Nfct,
GpioTE,
Saadc,
Timer,
Rtc,
Temp,
Rng,
Ecb,
Ccm,
Wdt,
Qdec,
Comp,
Egu,
Pwm,
Pdm,
Nvmc,
Ppi,
Mwu,
I2s,
Fpu,
Gpio,
Ficr,
Uicr,
}
pub struct MappedDevice {
device: Device,
address: usize,
size: usize,
}
const DEVICES: [MappedDevice; DEVICE_NB] = [
/* Power Monitoring Unit */
MappedDevice {
device: Device::Pmu,
address: 0x4000000,
size: 0x1000,
},
/* 2.4 GHz Radio */
MappedDevice {
device: Device::Radio,
address: 0x40001000,
size: 0x1000,
},
/* UART 0 */
MappedDevice {
device: Device::Uart,
address: 0x40002000,
size: 0x1000,
},
/* SPI 0 */
MappedDevice {
device: Device::Spi,
address: 0x40003000,
size: 0x1000,
},
/* SPI 1 */
MappedDevice {
device: Device::Spi,
address: 0x40004000,
size: 0x1000,
},
/* Near-Field Communication Tag */
MappedDevice {
device: Device::Nfct,
address: 0x40005000,
size: 0x1000,
},
/* GPIO Tasks and Events */
MappedDevice {
device: Device::GpioTE,
address: 0x40006000,
size: 0x1000,
},
/* Analog to digital converter */
MappedDevice {
device: Device::Saadc,
address: 0x40007000,
size: 0x1000,
},
/* Timer 0 */
MappedDevice {
device: Device::Timer,
address: 0x40008000,
size: 0x1000,
},
/* Timer 1 */
MappedDevice {
device: Device::Timer,
address: 0x40009000,
size: 0x1000,
},
/* Timer 2 */
MappedDevice {
device: Device::Timer,
address: 0x4000a000,
size: 0x1000,
},
/* RTC 0 */
MappedDevice {
device: Device::Rtc,
address: 0x4000b000,
size: 0x1000,
},
/* Temperature sensor */
MappedDevice {
device: Device::Temp,
address: 0x4000c000,
size: 0x1000,
},
/* Random Number Generator */
MappedDevice {
device: Device::Rng,
address: 0x4000d000,
size: 0x1000,
},
/* AES Electronic Code Book */
MappedDevice {
device: Device::Ecb,
address: 0x4000e000,
size: 0x1000,
},
/* AES CCM Mode Encryption */
MappedDevice {
device: Device::Ccm,
address: 0x4000f000,
size: 0x1000,
},
/* Watchdog Timer */
MappedDevice {
device: Device::Wdt,
address: 0x40010000,
size: 0x1000,
},
/* RTC 1 */
MappedDevice {
device: Device::Rtc,
address: 0x40011000,
size: 0x1000,
},
/* Quadrature Decoder */
MappedDevice {
device: Device::Qdec,
address: 0x40012000,
size: 0x1000,
},
/* General Purpose Comparator */
MappedDevice {
device: Device::Comp,
address: 0x40013000,
size: 0x1000,
},
/* Event Generator Unit 0 */
MappedDevice {
device: Device::Egu,
address: 0x40014000,
size: 0x1000,
},
/* Event Generator Unit 1 */
MappedDevice {
device: Device::Egu,
address: 0x40015000,
size: 0x1000,
},
/* Event Generator Unit 2 */
MappedDevice {
device: Device::Egu,
address: 0x40016000,
size: 0x1000,
},
/* Event Generator Unit 3 */
MappedDevice {
device: Device::Egu,
address: 0x40017000,
size: 0x1000,
},
/* Event Generator Unit 4 */
MappedDevice {
device: Device::Egu,
address: 0x40018000,
size: 0x1000,
},
/* Event Generator Unit 5 */
MappedDevice {
device: Device::Egu,
address: 0x40019000,
size: 0x1000,
},
/* Timer 3 */
MappedDevice {
device: Device::Timer,
address: 0x4001a000,
size: 0x1000,
},
/* Timer 4 */
MappedDevice {
device: Device::Timer,
address: 0x4001b000,
size: 0x1000,
},
/* Pulse Width Modulation Unit 0 */
MappedDevice {
device: Device::Pwm,
address: 0x4001c000,
size: 0x1000,
},
/* Pulse Density Modulation */
MappedDevice {
device: Device::Pdm,
address: 0x4001d000,
size: 0x1000,
},
/* Non-Volatile Memory Controller */
MappedDevice {
device: Device::Nvmc,
address: 0x4001e000,
size: 0x1000,
},
/* Programmable Peripheral Interconnect */
MappedDevice {
device: Device::Ppi,
address: 0x4001f000,
size: 0x1000,
},
/* Memory Watch Unit */
MappedDevice {
device: Device::Mwu,
address: 0x40020000,
size: 0x1000,
},
/* Pulse Width Modulation Unit 1 */
MappedDevice {
device: Device::Pwm,
address: 0x40021000,
size: 0x1000,
},
/* Pulse Width Modulation Unit 2 */
MappedDevice {
device: Device::Pwm,
address: 0x40022000,
size: 0x1000,
},
/* SPI 2 */
MappedDevice {
device: Device::Spi,
address: 0x40023000,
size: 0x1000,
},
/* RTC 2 */
MappedDevice {
device: Device::Rtc,
address: 0x40024000,
size: 0x1000,
},
/* Inter-IC Sound Interface */
MappedDevice {
device: Device::I2s,
address: 0x40025000,
size: 0x1000,
},
/* FPU Interrupt */
MappedDevice {
device: Device::Fpu,
address: 0x40026000,
size: 0x1000,
},
/* GPIO */
MappedDevice {
device: Device::Gpio,
address: 0x50000000,
size: 0x1000,
},
/* Factory Information Configuration */
MappedDevice {
device: Device::Ficr,
address: 0x10000000,
size: 0x1000,
},
/* User Information Configuration */
MappedDevice {
device: Device::Uicr,
address: 0x10001000,
size: 0x1000,
},
];

View file

@ -1,6 +1,7 @@
#![no_main] #![no_main]
#![no_std] #![no_std]
mod devices;
use core::{arch::global_asm, panic::PanicInfo}; use core::{arch::global_asm, panic::PanicInfo};
global_asm!(include_str!("bootstrap.s")); global_asm!(include_str!("bootstrap.s"));