lowrisc/
padctrl.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.

//! General Purpose Input/Output driver.

use kernel::utilities::registers::{register_bitfields, register_structs, ReadWrite};

register_structs! {
    pub PadCtrlRegisters {
        (0x00 => pub regen: ReadWrite<u32, REGEN::Register>),
        (0x04 => pub dio_pads: ReadWrite<u32, DIO_PADS::Register>),
        (0x08 => pub mio_pads0: ReadWrite<u32, DIO_PADS::Register>),
        (0x0c => pub mio_pads1: ReadWrite<u32, DIO_PADS::Register>),
        (0x10 => pub mio_pads2: ReadWrite<u32, DIO_PADS::Register>),
        (0x14 => pub mio_pads3: ReadWrite<u32, DIO_PADS::Register>),
        (0x18 => @END),
    }
}

register_bitfields![u32,
    pub REGEN [
        WEN OFFSET(0) NUMBITS(1) []
    ],
    pub DIO_PADS [
        ATTR0_IO_INV OFFSET(0) NUMBITS(1) [],
        ATTR0_OPEN_DRAIN OFFSET(1) NUMBITS(1) [],
        ATTR0_PULL_DOWN OFFSET(2) NUMBITS(1) [],
        ATTR0_PULL_UP OFFSET(3) NUMBITS(1) [],
        ATTR0_KEEPER OFFSET(4) NUMBITS(1) [],
        ATTR0_STRENGTH OFFSET(5) NUMBITS(1) [],
        ATTR1_IO_INV OFFSET(8) NUMBITS(1) [],
        ATTR1_OPEN_DRAIN OFFSET(9) NUMBITS(1) [],
        ATTR1_PULL_DOWN OFFSET(10) NUMBITS(1) [],
        ATTR1_PULL_UP OFFSET(11) NUMBITS(1) [],
        ATTR1_KEEPER OFFSET(12) NUMBITS(1) [],
        ATTR1_STRENGTH OFFSET(13) NUMBITS(1) [],
        ATTR2_IO_INV OFFSET(16) NUMBITS(1) [],
        ATTR2_OPEN_DRAIN OFFSET(17) NUMBITS(1) [],
        ATTR2_PULL_DOWN OFFSET(18) NUMBITS(1) [],
        ATTR2_PULL_UP OFFSET(19) NUMBITS(1) [],
        ATTR2_KEEPER OFFSET(20) NUMBITS(1) [],
        ATTR2_STRENGTH OFFSET(21) NUMBITS(1) [],
        ATTR3_IO_INV OFFSET(24) NUMBITS(1) [],
        ATTR3_OPEN_DRAIN OFFSET(25) NUMBITS(1) [],
        ATTR3_PULL_DOWN OFFSET(26) NUMBITS(1) [],
        ATTR3_PULL_UP OFFSET(27) NUMBITS(1) [],
        ATTR3_KEEPER OFFSET(28) NUMBITS(1) [],
        ATTR3_STRENGTH OFFSET(29) NUMBITS(1) []
    ]
];