diff options
| author | alexmoon <[email protected]> | 2022-03-29 17:13:16 -0400 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-06 05:38:11 +0200 |
| commit | d40ebcccf67c9848d9a22efd02eda9157955a4b4 (patch) | |
| tree | 458e165f32f8a8b84060a933151370272f53fc1f /embassy-usb/src/control.rs | |
| parent | 13370c28db244edd24029d6066ac9e448bd419c9 (diff) | |
Add handlers for standard reqs to ControlHandler
Diffstat (limited to 'embassy-usb/src/control.rs')
| -rw-r--r-- | embassy-usb/src/control.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/embassy-usb/src/control.rs b/embassy-usb/src/control.rs index 19c2c6776..b5077c732 100644 --- a/embassy-usb/src/control.rs +++ b/embassy-usb/src/control.rs | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | use core::mem; | 1 | use core::mem; |
| 2 | 2 | ||
| 3 | use crate::DEFAULT_ALTERNATE_SETTING; | ||
| 4 | |||
| 3 | use super::types::*; | 5 | use super::types::*; |
| 4 | 6 | ||
| 5 | /// Control request type. | 7 | /// Control request type. |
| @@ -153,6 +155,7 @@ pub trait ControlHandler { | |||
| 153 | /// * `req` - The request from the SETUP packet. | 155 | /// * `req` - The request from the SETUP packet. |
| 154 | /// * `data` - The data from the request. | 156 | /// * `data` - The data from the request. |
| 155 | fn control_out(&mut self, req: Request, data: &[u8]) -> OutResponse { | 157 | fn control_out(&mut self, req: Request, data: &[u8]) -> OutResponse { |
| 158 | let _ = (req, data); | ||
| 156 | OutResponse::Rejected | 159 | OutResponse::Rejected |
| 157 | } | 160 | } |
| 158 | 161 | ||
| @@ -165,6 +168,26 @@ pub trait ControlHandler { | |||
| 165 | /// | 168 | /// |
| 166 | /// * `req` - The request from the SETUP packet. | 169 | /// * `req` - The request from the SETUP packet. |
| 167 | fn control_in<'a>(&'a mut self, req: Request, buf: &'a mut [u8]) -> InResponse<'a> { | 170 | fn control_in<'a>(&'a mut self, req: Request, buf: &'a mut [u8]) -> InResponse<'a> { |
| 171 | let _ = (req, buf); | ||
| 168 | InResponse::Rejected | 172 | InResponse::Rejected |
| 169 | } | 173 | } |
| 174 | |||
| 175 | fn set_interface(&mut self, alternate_setting: u16) -> OutResponse { | ||
| 176 | if alternate_setting == u16::from(DEFAULT_ALTERNATE_SETTING) { | ||
| 177 | OutResponse::Accepted | ||
| 178 | } else { | ||
| 179 | OutResponse::Rejected | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | fn get_interface<'a>(&'a mut self, buf: &'a mut [u8]) -> InResponse<'a> { | ||
| 184 | buf[0] = DEFAULT_ALTERNATE_SETTING; | ||
| 185 | InResponse::Accepted(&buf[0..1]) | ||
| 186 | } | ||
| 187 | |||
| 188 | fn get_status<'a>(&'a mut self, buf: &'a mut [u8]) -> InResponse { | ||
| 189 | let status: u16 = 0; | ||
| 190 | buf[0..2].copy_from_slice(&status.to_le_bytes()); | ||
| 191 | InResponse::Accepted(&buf[0..2]) | ||
| 192 | } | ||
| 170 | } | 193 | } |
