Skip to content

Commit 2f2e629

Browse files
authored
Use auto-generated hardware/structs/ headers (based off SVD) SVD errors fixed.
1 parent a793222 commit 2f2e629

File tree

34 files changed

+3147
-257
lines changed

34 files changed

+3147
-257
lines changed

src/rp2040/hardware_regs/include/hardware/platform_defs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
#define NUM_UARTS _u(2)
2929
#define NUM_I2CS _u(2)
3030
#define NUM_SPIS _u(2)
31-
31+
#define NUM_TIMERS _u(4)
3232
#define NUM_ADC_CHANNELS _u(5)
3333

3434
#define NUM_BANK0_GPIOS _u(30)
35+
#define NUM_QSPI_GPIOS _u(6)
3536

3637
#define PIO_INSTRUCTION_COUNT _u(32)
3738

src/rp2040/hardware_structs/include/hardware/structs/adc.h

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,90 @@
1+
// THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
2+
13
/*
2-
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
4+
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
35
*
46
* SPDX-License-Identifier: BSD-3-Clause
57
*/
8+
69
#ifndef _HARDWARE_STRUCTS_ADC_H
710
#define _HARDWARE_STRUCTS_ADC_H
811

912
#include "hardware/address_mapped.h"
1013
#include "hardware/regs/adc.h"
1114

15+
// Reference to datasheet: https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf#tab-registerlist_adc
16+
//
17+
// The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature)
18+
// _REG_(x) will link to the corresponding register in hardware/regs/adc.h.
19+
//
20+
// Bit-field descriptions are of the form:
21+
// BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION
22+
1223
typedef struct {
24+
_REG_(ADC_CS_OFFSET) // ADC_CS
25+
// ADC Control and Status
26+
// 0x001f0000 [20:16] : RROBIN (0): Round-robin sampling
27+
// 0x00007000 [14:12] : AINSEL (0): Select analog mux input
28+
// 0x00000400 [10] : ERR_STICKY (0): Some past ADC conversion encountered an error
29+
// 0x00000200 [9] : ERR (0): The most recent ADC conversion encountered an error; result is undefined or noisy
30+
// 0x00000100 [8] : READY (0): 1 if the ADC is ready to start a new conversion
31+
// 0x00000008 [3] : START_MANY (0): Continuously perform conversions whilst this bit is 1
32+
// 0x00000004 [2] : START_ONCE (0): Start a single conversion
33+
// 0x00000002 [1] : TS_EN (0): Power on temperature sensor
34+
// 0x00000001 [0] : EN (0): Power on ADC and enable its clock
1335
io_rw_32 cs;
14-
io_rw_32 result;
36+
37+
_REG_(ADC_RESULT_OFFSET) // ADC_RESULT
38+
// Result of most recent ADC conversion
39+
// 0x00000fff [11:0] : RESULT (0)
40+
io_ro_32 result;
41+
42+
_REG_(ADC_FCS_OFFSET) // ADC_FCS
43+
// FIFO control and status
44+
// 0x0f000000 [27:24] : THRESH (0): DREQ/IRQ asserted when level >= threshold
45+
// 0x000f0000 [19:16] : LEVEL (0): The number of conversion results currently waiting in the FIFO
46+
// 0x00000800 [11] : OVER (0): 1 if the FIFO has been overflowed
47+
// 0x00000400 [10] : UNDER (0): 1 if the FIFO has been underflowed
48+
// 0x00000200 [9] : FULL (0)
49+
// 0x00000100 [8] : EMPTY (0)
50+
// 0x00000008 [3] : DREQ_EN (0): If 1: assert DMA requests when FIFO contains data
51+
// 0x00000004 [2] : ERR (0): If 1: conversion error bit appears in the FIFO alongside the result
52+
// 0x00000002 [1] : SHIFT (0): If 1: FIFO results are right-shifted to be one byte in size
53+
// 0x00000001 [0] : EN (0): If 1: write result to the FIFO after each conversion
1554
io_rw_32 fcs;
16-
io_rw_32 fifo;
55+
56+
_REG_(ADC_FIFO_OFFSET) // ADC_FIFO
57+
// Conversion result FIFO
58+
// 0x00008000 [15] : ERR (0): 1 if this particular sample experienced a conversion error
59+
// 0x00000fff [11:0] : VAL (0)
60+
io_ro_32 fifo;
61+
62+
_REG_(ADC_DIV_OFFSET) // ADC_DIV
63+
// Clock divider
64+
// 0x00ffff00 [23:8] : INT (0): Integer part of clock divisor
65+
// 0x000000ff [7:0] : FRAC (0): Fractional part of clock divisor
1766
io_rw_32 div;
18-
io_rw_32 intr;
67+
68+
_REG_(ADC_INTR_OFFSET) // ADC_INTR
69+
// Raw Interrupts
70+
// 0x00000001 [0] : FIFO (0): Triggered when the sample FIFO reaches a certain level
71+
io_ro_32 intr;
72+
73+
_REG_(ADC_INTE_OFFSET) // ADC_INTE
74+
// Interrupt Enable
75+
// 0x00000001 [0] : FIFO (0): Triggered when the sample FIFO reaches a certain level
1976
io_rw_32 inte;
77+
78+
_REG_(ADC_INTF_OFFSET) // ADC_INTF
79+
// Interrupt Force
80+
// 0x00000001 [0] : FIFO (0): Triggered when the sample FIFO reaches a certain level
2081
io_rw_32 intf;
21-
io_rw_32 ints;
22-
} adc_hw_t;
2382

24-
check_hw_layout(adc_hw_t, ints, ADC_INTS_OFFSET);
83+
_REG_(ADC_INTS_OFFSET) // ADC_INTS
84+
// Interrupt status after masking & forcing
85+
// 0x00000001 [0] : FIFO (0): Triggered when the sample FIFO reaches a certain level
86+
io_ro_32 ints;
87+
} adc_hw_t;
2588

2689
#define adc_hw ((adc_hw_t *const)ADC_BASE)
2790

src/rp2040/hardware_structs/include/hardware/structs/bus_ctrl.h

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1+
// THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
2+
13
/*
2-
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
4+
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
35
*
46
* SPDX-License-Identifier: BSD-3-Clause
57
*/
8+
69
#ifndef _HARDWARE_STRUCTS_BUS_CTRL_H
710
#define _HARDWARE_STRUCTS_BUS_CTRL_H
811

912
#include "hardware/address_mapped.h"
1013
#include "hardware/regs/busctrl.h"
1114

15+
// Reference to datasheet: https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf#tab-registerlist_busctrl
16+
//
17+
// The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature)
18+
// _REG_(x) will link to the corresponding register in hardware/regs/busctrl.h.
19+
//
20+
// Bit-field descriptions are of the form:
21+
// BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION
22+
1223
enum bus_ctrl_perf_counter {
1324
arbiter_rom_perf_event_access = 19,
1425
arbiter_rom_perf_event_access_contested = 18,
@@ -33,15 +44,33 @@ enum bus_ctrl_perf_counter {
3344
};
3445

3546
typedef struct {
47+
_REG_(BUSCTRL_PERFCTR0_OFFSET) // BUSCTRL_PERFCTR0
48+
// Bus fabric performance counter 0
49+
// 0x00ffffff [23:0] : PERFCTR0 (0): Busfabric saturating performance counter 0
50+
io_rw_32 value;
51+
52+
_REG_(BUSCTRL_PERFSEL0_OFFSET) // BUSCTRL_PERFSEL0
53+
// Bus fabric performance event select for PERFCTR0
54+
// 0x0000001f [4:0] : PERFSEL0 (0x1f): Select an event for PERFCTR0
55+
io_rw_32 sel;
56+
} bus_ctrl_perf_hw_t;
57+
58+
typedef struct {
59+
_REG_(BUSCTRL_BUS_PRIORITY_OFFSET) // BUSCTRL_BUS_PRIORITY
60+
// Set the priority of each master for bus arbitration
61+
// 0x00001000 [12] : DMA_W (0): 0 - low priority, 1 - high priority
62+
// 0x00000100 [8] : DMA_R (0): 0 - low priority, 1 - high priority
63+
// 0x00000010 [4] : PROC1 (0): 0 - low priority, 1 - high priority
64+
// 0x00000001 [0] : PROC0 (0): 0 - low priority, 1 - high priority
3665
io_rw_32 priority;
66+
67+
_REG_(BUSCTRL_BUS_PRIORITY_ACK_OFFSET) // BUSCTRL_BUS_PRIORITY_ACK
68+
// Bus priority acknowledge
69+
// 0x00000001 [0] : BUS_PRIORITY_ACK (0): Goes to 1 once all arbiters have registered the new global priority levels
3770
io_ro_32 priority_ack;
38-
struct {
39-
io_rw_32 value;
40-
io_rw_32 sel;
41-
} counter[4];
42-
} bus_ctrl_hw_t;
4371

44-
check_hw_layout(bus_ctrl_hw_t, counter[0].value, BUSCTRL_PERFCTR0_OFFSET);
72+
bus_ctrl_perf_hw_t counter[4];
73+
} bus_ctrl_hw_t;
4574

4675
#define bus_ctrl_hw ((bus_ctrl_hw_t *const)BUSCTRL_BASE)
4776

0 commit comments

Comments
 (0)