From: Tilman Sauerbeck Date: Mon, 17 Jun 2019 19:51:36 +0000 (+0200) Subject: common: Implement USB_DeviceIsrEnable() and USB_DeviceClockInit(). X-Git-Url: http://git.code-monkey.de/?p=gps-watch.git;a=commitdiff_plain;h=cec0c36c6bade2106fba5e4bb1ea0180b1aef6a6 common: Implement USB_DeviceIsrEnable() and USB_DeviceClockInit(). These functions are required by the C implementation. --- diff --git a/src/common/usb_serial.rs b/src/common/usb_serial.rs index f08f679..c9de0d4 100644 --- a/src/common/usb_serial.rs +++ b/src/common/usb_serial.rs @@ -21,6 +21,9 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use nvic; +use clock; + extern { fn USB_VcomInit(); } @@ -28,3 +31,21 @@ extern { pub unsafe fn init() { USB_VcomInit(); } + +#[no_mangle] +#[allow(non_snake_case)] +pub unsafe extern fn USB_DeviceIsrEnable() +{ + let irq_number = 24; // USB0 + let irq_prio = 3; // Stolen from NXP example. + + nvic::set_priority(irq_number, irq_prio); + nvic::enable_irq(irq_number); +} + +#[no_mangle] +#[allow(non_snake_case)] +pub unsafe extern fn USB_DeviceClockInit() +{ + clock::configure_usb(); +}