summaryrefslogtreecommitdiff
path: root/chip/stm32/usb.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-02-22 17:01:18 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-23 16:02:05 -0800
commit8290f06283114060cf752bc98561e7c295cdab6f (patch)
tree5a0c6fc239880c7b6718c5efcfde6adc37f11811 /chip/stm32/usb.c
parent6d9dd9502e1ed28e12a64e68dea5b4960f1bd105 (diff)
downloadchrome-ec-8290f06283114060cf752bc98561e7c295cdab6f.tar.gz
stm32/usb: Add useful register macros instead of hardcoding values
Hopefully makes the code a little easier to understand, and will be useful for future features. BRANCH=none BUG=chrome-os-partner:62325 TEST=build and flash hammer Change-Id: I2b562740794c165da4e6611be371926e737f3887 Reviewed-on: https://chromium-review.googlesource.com/446238 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32/usb.c')
-rw-r--r--chip/stm32/usb.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 2afab3f415..ea34877c6d 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -296,13 +296,13 @@ void usb_interrupt(void)
{
uint16_t status = STM32_USB_ISTR;
- if ((status & (1 << 10)))
+ if (status & STM32_USB_ISTR_RESET)
usb_reset();
- if (status & (1 << 15)) {
- int ep = status & 0x000f;
+ if (status & STM32_USB_ISTR_CTR) {
+ int ep = status & STM32_USB_ISTR_EP_ID_MASK;
if (ep < USB_EP_COUNT) {
- if (status & 0x0010)
+ if (status & STM32_USB_ISTR_DIR)
usb_ep_rx[ep]();
else
usb_ep_tx[ep]();
@@ -330,7 +330,7 @@ void usb_init(void)
/* power on sequence */
/* keep FRES (USB reset) and remove PDWN (power down) */
- STM32_USB_CNTR = 0x01;
+ STM32_USB_CNTR = STM32_USB_CNTR_FRES;
udelay(1); /* startup time */
/* reset FRES and keep interrupts masked */
STM32_USB_CNTR = 0x00;
@@ -347,7 +347,10 @@ void usb_init(void)
/* Enable interrupt handlers */
task_enable_irq(STM32_IRQ_USB_LP);
/* set interrupts mask : reset/correct transfer/errors */
- STM32_USB_CNTR = 0xe400;
+ STM32_USB_CNTR = STM32_USB_CNTR_CTRM |
+ STM32_USB_CNTR_PMAOVRM |
+ STM32_USB_CNTR_ERRM |
+ STM32_USB_CNTR_RESETM;
#ifdef CONFIG_USB_SERIALNO
usb_load_serial();