diff options
| author | Daniel Bevenius <[email protected]> | 2022-09-23 13:29:33 +0200 |
|---|---|---|
| committer | Daniel Bevenius <[email protected]> | 2022-09-26 14:08:50 +0200 |
| commit | 9962db4ecf227792d777ff0bc91d9e4d50d24f85 (patch) | |
| tree | 2358d183ffb04132695f8f478b18df392d634e60 /src/lib.rs | |
| parent | 79a9a4eb9898b4e56544f78729b6e8960c884960 (diff) | |
Suppress compiler warnings
This commit adds the allow(unused) attribute to functions and constants
that are not currently used. There is one warning remaining but
https://github.com/embassy-rs/cyw43/pull/23 attempts to address that
one. The constants have been moved into a module to allow the attribute
to be applied to the module as a whole.
The motivation for this is that it will hopefully make it easier to
spot new warnings that might be introduced by new, or updated code.
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 220 |
1 files changed, 115 insertions, 105 deletions
diff --git a/src/lib.rs b/src/lib.rs index c7e0285f9..b8ce2e2a2 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -32,13 +32,6 @@ fn swap16(x: u32) -> u32 { | |||
| 32 | x.rotate_left(16) | 32 | x.rotate_left(16) |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | // CYW_SPID command structure constants. | ||
| 36 | const WRITE: bool = true; | ||
| 37 | const READ: bool = false; | ||
| 38 | const INC_ADDR: bool = true; | ||
| 39 | #[allow(unused)] | ||
| 40 | const FIXED_ADDR: bool = false; | ||
| 41 | |||
| 42 | fn cmd_word(write: bool, incr: bool, func: u32, addr: u32, len: u32) -> u32 { | 35 | fn cmd_word(write: bool, incr: bool, func: u32, addr: u32, len: u32) -> u32 { |
| 43 | (write as u32) << 31 | (incr as u32) << 30 | (func & 0b11) << 28 | (addr & 0x1FFFF) << 11 | (len & 0x7FF) | 36 | (write as u32) << 31 | (incr as u32) << 30 | (func & 0b11) << 28 | (addr & 0x1FFFF) << 11 | (len & 0x7FF) |
| 44 | } | 37 | } |
| @@ -48,104 +41,114 @@ fn slice8_mut(x: &mut [u32]) -> &mut [u8] { | |||
| 48 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } | 41 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } |
| 49 | } | 42 | } |
| 50 | 43 | ||
| 51 | const FUNC_BUS: u32 = 0; | 44 | mod constants { |
| 52 | const FUNC_BACKPLANE: u32 = 1; | 45 | #![allow(unused)] |
| 53 | const FUNC_WLAN: u32 = 2; | 46 | pub(crate) const FUNC_BUS: u32 = 0; |
| 54 | const FUNC_BT: u32 = 3; | 47 | pub(crate) const FUNC_BACKPLANE: u32 = 1; |
| 55 | 48 | pub(crate) const FUNC_WLAN: u32 = 2; | |
| 56 | const REG_BUS_CTRL: u32 = 0x0; | 49 | pub(crate) const FUNC_BT: u32 = 3; |
| 57 | const REG_BUS_INTERRUPT: u32 = 0x04; // 16 bits - Interrupt status | 50 | |
| 58 | const REG_BUS_INTERRUPT_ENABLE: u32 = 0x06; // 16 bits - Interrupt mask | 51 | pub(crate) const REG_BUS_CTRL: u32 = 0x0; |
| 59 | const REG_BUS_STATUS: u32 = 0x8; | 52 | pub(crate) const REG_BUS_INTERRUPT: u32 = 0x04; // 16 bits - Interrupt status |
| 60 | const REG_BUS_TEST_RO: u32 = 0x14; | 53 | pub(crate) const REG_BUS_INTERRUPT_ENABLE: u32 = 0x06; // 16 bits - Interrupt mask |
| 61 | const REG_BUS_TEST_RW: u32 = 0x18; | 54 | pub(crate) const REG_BUS_STATUS: u32 = 0x8; |
| 62 | const REG_BUS_RESP_DELAY: u32 = 0x1c; | 55 | pub(crate) const REG_BUS_TEST_RO: u32 = 0x14; |
| 63 | const WORD_LENGTH_32: u32 = 0x1; | 56 | pub(crate) const REG_BUS_TEST_RW: u32 = 0x18; |
| 64 | const HIGH_SPEED: u32 = 0x10; | 57 | pub(crate) const REG_BUS_RESP_DELAY: u32 = 0x1c; |
| 65 | 58 | pub(crate) const WORD_LENGTH_32: u32 = 0x1; | |
| 66 | // SPI_STATUS_REGISTER bits | 59 | pub(crate) const HIGH_SPEED: u32 = 0x10; |
| 67 | const STATUS_DATA_NOT_AVAILABLE: u32 = 0x00000001; | 60 | |
| 68 | const STATUS_UNDERFLOW: u32 = 0x00000002; | 61 | // SPI_STATUS_REGISTER bits |
| 69 | const STATUS_OVERFLOW: u32 = 0x00000004; | 62 | pub(crate) const STATUS_DATA_NOT_AVAILABLE: u32 = 0x00000001; |
| 70 | const STATUS_F2_INTR: u32 = 0x00000008; | 63 | pub(crate) const STATUS_UNDERFLOW: u32 = 0x00000002; |
| 71 | const STATUS_F3_INTR: u32 = 0x00000010; | 64 | pub(crate) const STATUS_OVERFLOW: u32 = 0x00000004; |
| 72 | const STATUS_F2_RX_READY: u32 = 0x00000020; | 65 | pub(crate) const STATUS_F2_INTR: u32 = 0x00000008; |
| 73 | const STATUS_F3_RX_READY: u32 = 0x00000040; | 66 | pub(crate) const STATUS_F3_INTR: u32 = 0x00000010; |
| 74 | const STATUS_HOST_CMD_DATA_ERR: u32 = 0x00000080; | 67 | pub(crate) const STATUS_F2_RX_READY: u32 = 0x00000020; |
| 75 | const STATUS_F2_PKT_AVAILABLE: u32 = 0x00000100; | 68 | pub(crate) const STATUS_F3_RX_READY: u32 = 0x00000040; |
| 76 | const STATUS_F2_PKT_LEN_MASK: u32 = 0x000FFE00; | 69 | pub(crate) const STATUS_HOST_CMD_DATA_ERR: u32 = 0x00000080; |
| 77 | const STATUS_F2_PKT_LEN_SHIFT: u32 = 9; | 70 | pub(crate) const STATUS_F2_PKT_AVAILABLE: u32 = 0x00000100; |
| 78 | const STATUS_F3_PKT_AVAILABLE: u32 = 0x00100000; | 71 | pub(crate) const STATUS_F2_PKT_LEN_MASK: u32 = 0x000FFE00; |
| 79 | const STATUS_F3_PKT_LEN_MASK: u32 = 0xFFE00000; | 72 | pub(crate) const STATUS_F2_PKT_LEN_SHIFT: u32 = 9; |
| 80 | const STATUS_F3_PKT_LEN_SHIFT: u32 = 21; | 73 | pub(crate) const STATUS_F3_PKT_AVAILABLE: u32 = 0x00100000; |
| 81 | 74 | pub(crate) const STATUS_F3_PKT_LEN_MASK: u32 = 0xFFE00000; | |
| 82 | const REG_BACKPLANE_GPIO_SELECT: u32 = 0x10005; | 75 | pub(crate) const STATUS_F3_PKT_LEN_SHIFT: u32 = 21; |
| 83 | const REG_BACKPLANE_GPIO_OUTPUT: u32 = 0x10006; | 76 | |
| 84 | const REG_BACKPLANE_GPIO_ENABLE: u32 = 0x10007; | 77 | pub(crate) const REG_BACKPLANE_GPIO_SELECT: u32 = 0x10005; |
| 85 | const REG_BACKPLANE_FUNCTION2_WATERMARK: u32 = 0x10008; | 78 | pub(crate) const REG_BACKPLANE_GPIO_OUTPUT: u32 = 0x10006; |
| 86 | const REG_BACKPLANE_DEVICE_CONTROL: u32 = 0x10009; | 79 | pub(crate) const REG_BACKPLANE_GPIO_ENABLE: u32 = 0x10007; |
| 87 | const REG_BACKPLANE_BACKPLANE_ADDRESS_LOW: u32 = 0x1000A; | 80 | pub(crate) const REG_BACKPLANE_FUNCTION2_WATERMARK: u32 = 0x10008; |
| 88 | const REG_BACKPLANE_BACKPLANE_ADDRESS_MID: u32 = 0x1000B; | 81 | pub(crate) const REG_BACKPLANE_DEVICE_CONTROL: u32 = 0x10009; |
| 89 | const REG_BACKPLANE_BACKPLANE_ADDRESS_HIGH: u32 = 0x1000C; | 82 | pub(crate) const REG_BACKPLANE_BACKPLANE_ADDRESS_LOW: u32 = 0x1000A; |
| 90 | const REG_BACKPLANE_FRAME_CONTROL: u32 = 0x1000D; | 83 | pub(crate) const REG_BACKPLANE_BACKPLANE_ADDRESS_MID: u32 = 0x1000B; |
| 91 | const REG_BACKPLANE_CHIP_CLOCK_CSR: u32 = 0x1000E; | 84 | pub(crate) const REG_BACKPLANE_BACKPLANE_ADDRESS_HIGH: u32 = 0x1000C; |
| 92 | const REG_BACKPLANE_PULL_UP: u32 = 0x1000F; | 85 | pub(crate) const REG_BACKPLANE_FRAME_CONTROL: u32 = 0x1000D; |
| 93 | const REG_BACKPLANE_READ_FRAME_BC_LOW: u32 = 0x1001B; | 86 | pub(crate) const REG_BACKPLANE_CHIP_CLOCK_CSR: u32 = 0x1000E; |
| 94 | const REG_BACKPLANE_READ_FRAME_BC_HIGH: u32 = 0x1001C; | 87 | pub(crate) const REG_BACKPLANE_PULL_UP: u32 = 0x1000F; |
| 95 | const REG_BACKPLANE_WAKEUP_CTRL: u32 = 0x1001E; | 88 | pub(crate) const REG_BACKPLANE_READ_FRAME_BC_LOW: u32 = 0x1001B; |
| 96 | const REG_BACKPLANE_SLEEP_CSR: u32 = 0x1001F; | 89 | pub(crate) const REG_BACKPLANE_READ_FRAME_BC_HIGH: u32 = 0x1001C; |
| 97 | 90 | pub(crate) const REG_BACKPLANE_WAKEUP_CTRL: u32 = 0x1001E; | |
| 98 | const BACKPLANE_WINDOW_SIZE: usize = 0x8000; | 91 | pub(crate) const REG_BACKPLANE_SLEEP_CSR: u32 = 0x1001F; |
| 99 | const BACKPLANE_ADDRESS_MASK: u32 = 0x7FFF; | 92 | |
| 100 | const BACKPLANE_ADDRESS_32BIT_FLAG: u32 = 0x08000; | 93 | pub(crate) const BACKPLANE_WINDOW_SIZE: usize = 0x8000; |
| 101 | const BACKPLANE_MAX_TRANSFER_SIZE: usize = 64; | 94 | pub(crate) const BACKPLANE_ADDRESS_MASK: u32 = 0x7FFF; |
| 102 | // Active Low Power (ALP) clock constants | 95 | pub(crate) const BACKPLANE_ADDRESS_32BIT_FLAG: u32 = 0x08000; |
| 103 | const BACKPLANE_ALP_AVAIL_REQ: u8 = 0x08; | 96 | pub(crate) const BACKPLANE_MAX_TRANSFER_SIZE: usize = 64; |
| 104 | const BACKPLANE_ALP_AVAIL: u8 = 0x40; | 97 | // Active Low Power (ALP) clock constants |
| 105 | 98 | pub(crate) const BACKPLANE_ALP_AVAIL_REQ: u8 = 0x08; | |
| 106 | // Broadcom AMBA (Advanced Microcontroller Bus Architecture) Interconnect (AI) | 99 | pub(crate) const BACKPLANE_ALP_AVAIL: u8 = 0x40; |
| 107 | // constants | 100 | |
| 108 | const AI_IOCTRL_OFFSET: u32 = 0x408; | 101 | // Broadcom AMBA (Advanced Microcontroller Bus Architecture) Interconnect |
| 109 | const AI_IOCTRL_BIT_FGC: u8 = 0x0002; | 102 | // (AI) pub (crate) constants |
| 110 | const AI_IOCTRL_BIT_CLOCK_EN: u8 = 0x0001; | 103 | pub(crate) const AI_IOCTRL_OFFSET: u32 = 0x408; |
| 111 | const AI_IOCTRL_BIT_CPUHALT: u8 = 0x0020; | 104 | pub(crate) const AI_IOCTRL_BIT_FGC: u8 = 0x0002; |
| 112 | 105 | pub(crate) const AI_IOCTRL_BIT_CLOCK_EN: u8 = 0x0001; | |
| 113 | const AI_RESETCTRL_OFFSET: u32 = 0x800; | 106 | pub(crate) const AI_IOCTRL_BIT_CPUHALT: u8 = 0x0020; |
| 114 | const AI_RESETCTRL_BIT_RESET: u8 = 1; | 107 | |
| 115 | 108 | pub(crate) const AI_RESETCTRL_OFFSET: u32 = 0x800; | |
| 116 | const AI_RESETSTATUS_OFFSET: u32 = 0x804; | 109 | pub(crate) const AI_RESETCTRL_BIT_RESET: u8 = 1; |
| 117 | 110 | ||
| 118 | const TEST_PATTERN: u32 = 0x12345678; | 111 | pub(crate) const AI_RESETSTATUS_OFFSET: u32 = 0x804; |
| 119 | const FEEDBEAD: u32 = 0xFEEDBEAD; | 112 | |
| 120 | 113 | pub(crate) const TEST_PATTERN: u32 = 0x12345678; | |
| 121 | // SPI_INTERRUPT_REGISTER and SPI_INTERRUPT_ENABLE_REGISTER Bits | 114 | pub(crate) const FEEDBEAD: u32 = 0xFEEDBEAD; |
| 122 | const IRQ_DATA_UNAVAILABLE: u16 = 0x0001; // Requested data not available; Clear by writing a "1" | 115 | |
| 123 | const IRQ_F2_F3_FIFO_RD_UNDERFLOW: u16 = 0x0002; | 116 | // SPI_INTERRUPT_REGISTER and SPI_INTERRUPT_ENABLE_REGISTER Bits |
| 124 | const IRQ_F2_F3_FIFO_WR_OVERFLOW: u16 = 0x0004; | 117 | pub(crate) const IRQ_DATA_UNAVAILABLE: u16 = 0x0001; // Requested data not available; Clear by writing a "1" |
| 125 | const IRQ_COMMAND_ERROR: u16 = 0x0008; // Cleared by writing 1 | 118 | pub(crate) const IRQ_F2_F3_FIFO_RD_UNDERFLOW: u16 = 0x0002; |
| 126 | const IRQ_DATA_ERROR: u16 = 0x0010; // Cleared by writing 1 | 119 | pub(crate) const IRQ_F2_F3_FIFO_WR_OVERFLOW: u16 = 0x0004; |
| 127 | const IRQ_F2_PACKET_AVAILABLE: u16 = 0x0020; | 120 | pub(crate) const IRQ_COMMAND_ERROR: u16 = 0x0008; // Cleared by writing 1 |
| 128 | const IRQ_F3_PACKET_AVAILABLE: u16 = 0x0040; | 121 | pub(crate) const IRQ_DATA_ERROR: u16 = 0x0010; // Cleared by writing 1 |
| 129 | const IRQ_F1_OVERFLOW: u16 = 0x0080; // Due to last write. Bkplane has pending write requests | 122 | pub(crate) const IRQ_F2_PACKET_AVAILABLE: u16 = 0x0020; |
| 130 | const IRQ_MISC_INTR0: u16 = 0x0100; | 123 | pub(crate) const IRQ_F3_PACKET_AVAILABLE: u16 = 0x0040; |
| 131 | const IRQ_MISC_INTR1: u16 = 0x0200; | 124 | pub(crate) const IRQ_F1_OVERFLOW: u16 = 0x0080; // Due to last write. Bkplane has pending write requests |
| 132 | const IRQ_MISC_INTR2: u16 = 0x0400; | 125 | pub(crate) const IRQ_MISC_INTR0: u16 = 0x0100; |
| 133 | const IRQ_MISC_INTR3: u16 = 0x0800; | 126 | pub(crate) const IRQ_MISC_INTR1: u16 = 0x0200; |
| 134 | const IRQ_MISC_INTR4: u16 = 0x1000; | 127 | pub(crate) const IRQ_MISC_INTR2: u16 = 0x0400; |
| 135 | const IRQ_F1_INTR: u16 = 0x2000; | 128 | pub(crate) const IRQ_MISC_INTR3: u16 = 0x0800; |
| 136 | const IRQ_F2_INTR: u16 = 0x4000; | 129 | pub(crate) const IRQ_MISC_INTR4: u16 = 0x1000; |
| 137 | const IRQ_F3_INTR: u16 = 0x8000; | 130 | pub(crate) const IRQ_F1_INTR: u16 = 0x2000; |
| 138 | 131 | pub(crate) const IRQ_F2_INTR: u16 = 0x4000; | |
| 139 | const IOCTL_CMD_UP: u32 = 2; | 132 | pub(crate) const IRQ_F3_INTR: u16 = 0x8000; |
| 140 | const IOCTL_CMD_SET_SSID: u32 = 26; | 133 | |
| 141 | const IOCTL_CMD_ANTDIV: u32 = 64; | 134 | pub(crate) const IOCTL_CMD_UP: u32 = 2; |
| 142 | const IOCTL_CMD_SET_VAR: u32 = 263; | 135 | pub(crate) const IOCTL_CMD_SET_SSID: u32 = 26; |
| 143 | const IOCTL_CMD_GET_VAR: u32 = 262; | 136 | pub(crate) const IOCTL_CMD_ANTDIV: u32 = 64; |
| 144 | const IOCTL_CMD_SET_PASSPHRASE: u32 = 268; | 137 | pub(crate) const IOCTL_CMD_SET_VAR: u32 = 263; |
| 145 | 138 | pub(crate) const IOCTL_CMD_GET_VAR: u32 = 262; | |
| 146 | const CHANNEL_TYPE_CONTROL: u8 = 0; | 139 | pub(crate) const IOCTL_CMD_SET_PASSPHRASE: u32 = 268; |
| 147 | const CHANNEL_TYPE_EVENT: u8 = 1; | 140 | |
| 148 | const CHANNEL_TYPE_DATA: u8 = 2; | 141 | pub(crate) const CHANNEL_TYPE_CONTROL: u8 = 0; |
| 142 | pub(crate) const CHANNEL_TYPE_EVENT: u8 = 1; | ||
| 143 | pub(crate) const CHANNEL_TYPE_DATA: u8 = 2; | ||
| 144 | |||
| 145 | // CYW_SPID command structure constants. | ||
| 146 | pub(crate) const WRITE: bool = true; | ||
| 147 | pub(crate) const READ: bool = false; | ||
| 148 | pub(crate) const INC_ADDR: bool = true; | ||
| 149 | pub(crate) const FIXED_ADDR: bool = false; | ||
| 150 | } | ||
| 151 | use crate::constants::*; | ||
| 149 | 152 | ||
| 150 | #[derive(Clone, Copy)] | 153 | #[derive(Clone, Copy)] |
| 151 | pub enum IoctlType { | 154 | pub enum IoctlType { |
| @@ -153,6 +156,7 @@ pub enum IoctlType { | |||
| 153 | Set = 2, | 156 | Set = 2, |
| 154 | } | 157 | } |
| 155 | 158 | ||
| 159 | #[allow(unused)] | ||
| 156 | #[derive(Clone, Copy, PartialEq, Eq)] | 160 | #[derive(Clone, Copy, PartialEq, Eq)] |
| 157 | enum Core { | 161 | enum Core { |
| 158 | WLAN = 0, | 162 | WLAN = 0, |
| @@ -170,6 +174,7 @@ impl Core { | |||
| 170 | } | 174 | } |
| 171 | } | 175 | } |
| 172 | 176 | ||
| 177 | #[allow(unused)] | ||
| 173 | struct Chip { | 178 | struct Chip { |
| 174 | arm_core_base_address: u32, | 179 | arm_core_base_address: u32, |
| 175 | socsram_base_address: u32, | 180 | socsram_base_address: u32, |
| @@ -1077,6 +1082,7 @@ where | |||
| 1077 | true | 1082 | true |
| 1078 | } | 1083 | } |
| 1079 | 1084 | ||
| 1085 | #[allow(unused)] | ||
| 1080 | async fn bp_read(&mut self, mut addr: u32, mut data: &mut [u32]) { | 1086 | async fn bp_read(&mut self, mut addr: u32, mut data: &mut [u32]) { |
| 1081 | // It seems the HW force-aligns the addr | 1087 | // It seems the HW force-aligns the addr |
| 1082 | // to 2 if data.len() >= 2 | 1088 | // to 2 if data.len() >= 2 |
| @@ -1170,10 +1176,12 @@ where | |||
| 1170 | self.backplane_readn(addr, 2).await as u16 | 1176 | self.backplane_readn(addr, 2).await as u16 |
| 1171 | } | 1177 | } |
| 1172 | 1178 | ||
| 1179 | #[allow(unused)] | ||
| 1173 | async fn bp_write16(&mut self, addr: u32, val: u16) { | 1180 | async fn bp_write16(&mut self, addr: u32, val: u16) { |
| 1174 | self.backplane_writen(addr, val as u32, 2).await | 1181 | self.backplane_writen(addr, val as u32, 2).await |
| 1175 | } | 1182 | } |
| 1176 | 1183 | ||
| 1184 | #[allow(unused)] | ||
| 1177 | async fn bp_read32(&mut self, addr: u32) -> u32 { | 1185 | async fn bp_read32(&mut self, addr: u32) -> u32 { |
| 1178 | self.backplane_readn(addr, 4).await | 1186 | self.backplane_readn(addr, 4).await |
| 1179 | } | 1187 | } |
| @@ -1244,6 +1252,7 @@ where | |||
| 1244 | self.readn(func, addr, 2).await as u16 | 1252 | self.readn(func, addr, 2).await as u16 |
| 1245 | } | 1253 | } |
| 1246 | 1254 | ||
| 1255 | #[allow(unused)] | ||
| 1247 | async fn write16(&mut self, func: u32, addr: u32, val: u16) { | 1256 | async fn write16(&mut self, func: u32, addr: u32, val: u16) { |
| 1248 | self.writen(func, addr, val as u32, 2).await | 1257 | self.writen(func, addr, val as u32, 2).await |
| 1249 | } | 1258 | } |
| @@ -1252,6 +1261,7 @@ where | |||
| 1252 | self.readn(func, addr, 4).await | 1261 | self.readn(func, addr, 4).await |
| 1253 | } | 1262 | } |
| 1254 | 1263 | ||
| 1264 | #[allow(unused)] | ||
| 1255 | async fn write32(&mut self, func: u32, addr: u32, val: u32) { | 1265 | async fn write32(&mut self, func: u32, addr: u32, val: u32) { |
| 1256 | self.writen(func, addr, val, 4).await | 1266 | self.writen(func, addr, val, 4).await |
| 1257 | } | 1267 | } |
