From b72a5f5e8e97ba86736c1e26b4204fc6d0c215da Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 19 May 2015 00:00:23 -0700 Subject: discovery-stm32f072: Blink the LEDs This just makes the LEDs blink continually, because I have a development board sitting on my desk and I like to see it doing something. You can still force the GPIOs on and off using the tool in extra/usb_gpio/. BUG=none BRANCH=none TEST=make buildall Try it: sudo make BOARD=discovery-stm32f072 flash The LEDs blink. Force them on and off with: cd extra/usb_gpio make ./usb_gpio write -1 0 ./usb_gpio write 0 -1 ./usb_gpio write 2 0 ./usb_gpio write 4 2 To resume blinking, use ./usb_gpio write 0 0 Change-Id: Iadbe7436c02de5b6eae81885d95bad154ca3692c Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/274131 Reviewed-by: Anton Staaf --- chip/stm32/usb_gpio.c | 3 +++ chip/stm32/usb_gpio.h | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'chip') diff --git a/chip/stm32/usb_gpio.c b/chip/stm32/usb_gpio.c index 027ddadaae..43cda832a8 100644 --- a/chip/stm32/usb_gpio.c +++ b/chip/stm32/usb_gpio.c @@ -39,6 +39,9 @@ void usb_gpio_rx(struct usb_gpio_config const *config) (uint32_t)(config->rx_ram[3]) << 16); uint32_t ignore_mask = set_mask & clear_mask; + config->state->set_mask = set_mask; + config->state->clear_mask = clear_mask; + if ((btable_ep[config->endpoint].rx_count & 0x3ff) == USB_GPIO_RX_PACKET_SIZE) { for (i = 0; i < config->num_gpios; ++i, mask <<= 1) { diff --git a/chip/stm32/usb_gpio.h b/chip/stm32/usb_gpio.h index 2027df9d21..56f3d72c57 100644 --- a/chip/stm32/usb_gpio.h +++ b/chip/stm32/usb_gpio.h @@ -10,12 +10,19 @@ #include "compile_time_macros.h" #include "usb.h" +struct usb_gpio_state { + uint32_t set_mask; + uint32_t clear_mask; +}; + /* * Compile time Per-USB gpio configuration stored in flash. Instances of this * structure are provided by the user of the USB gpio. This structure binds * together all information required to operate a USB gpio. */ struct usb_gpio_config { + struct usb_gpio_state *state; + /* * Endpoint index, and pointers to the USB packet RAM buffers. */ @@ -55,6 +62,7 @@ struct usb_gpio_config { static usb_uint CONCAT2(NAME, _ep_rx_buffer)[USB_GPIO_RX_PACKET_SIZE / 2] __usb_ram; \ static usb_uint CONCAT2(NAME, _ep_tx_buffer)[USB_GPIO_TX_PACKET_SIZE / 2] __usb_ram; \ struct usb_gpio_config const NAME = { \ + .state = &((struct usb_gpio_state){}), \ .endpoint = ENDPOINT, \ .rx_ram = CONCAT2(NAME, _ep_rx_buffer), \ .tx_ram = CONCAT2(NAME, _ep_tx_buffer), \ @@ -106,7 +114,8 @@ struct usb_gpio_config { USB_DECLARE_EP(ENDPOINT, \ CONCAT2(NAME, _ep_tx), \ CONCAT2(NAME, _ep_rx), \ - CONCAT2(NAME, _ep_reset)); + CONCAT2(NAME, _ep_reset)) + /* * These functions are used by the trampoline functions defined above to -- cgit v1.2.1