Corrected led io for lisa/m v1.1 cleaned up some whitespace. Trying to get it to work...

This commit is contained in:
Piotr Esden-Tempski
2011-10-04 23:53:16 -07:00
parent 03a4a18ed6
commit 9e4522ad21

View File

@@ -2,6 +2,7 @@
* This file is part of the libopencm3 project. * This file is part of the libopencm3 project.
* *
* Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz> * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
* Copyright (C) 2011 Piotr Esden-Tempski <piotr@esden.net>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -33,20 +34,20 @@
#endif #endif
const struct usb_device_descriptor dev = { const struct usb_device_descriptor dev = {
.bLength = USB_DT_DEVICE_SIZE, .bLength = USB_DT_DEVICE_SIZE,
.bDescriptorType = USB_DT_DEVICE, .bDescriptorType = USB_DT_DEVICE,
.bcdUSB = 0x0200, .bcdUSB = 0x0200,
.bDeviceClass = 0, .bDeviceClass = 0,
.bDeviceSubClass = 0, .bDeviceSubClass = 0,
.bDeviceProtocol = 0, .bDeviceProtocol = 0,
.bMaxPacketSize0 = 64, .bMaxPacketSize0 = 64,
.idVendor = 0x0483, .idVendor = 0x0483,
.idProduct = 0x5710, .idProduct = 0x5710,
.bcdDevice = 0x0200, .bcdDevice = 0x0200,
.iManufacturer = 1, .iManufacturer = 1,
.iProduct = 2, .iProduct = 2,
.iSerialNumber = 3, .iSerialNumber = 3,
.bNumConfigurations = 1, .bNumConfigurations = 1,
}; };
/* I have no idea what this means. I haven't read the HID spec. */ /* I have no idea what this means. I haven't read the HID spec. */
@@ -238,7 +239,8 @@ static void hid_set_config(u16 wValue)
int main(void) int main(void)
{ {
rcc_clock_setup_in_hsi_out_48mhz(); int usb_connect_blink = 0;
rcc_clock_setup_in_hsi_out_48mhz();
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN); rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
@@ -254,23 +256,25 @@ int main(void)
GPIO_CNF_OUTPUT_PUSHPULL, GPIO15); GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
/* green LED off, as output */ /* green LED off, as output */
gpio_clear(GPIOC, GPIO13); gpio_set(GPIOC, GPIO2);
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO13); GPIO_CNF_OUTPUT_PUSHPULL, GPIO2);
usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings); usbd_init(&stm32f107_usb_driver, &dev, &config, usb_strings);
usbd_register_set_config_callback(hid_set_config); usbd_register_set_config_callback(hid_set_config);
/* delay some seconds to show that pull-up switch works */ /* delay some seconds to show that pull-up switch works */
{int i; for (i=0;i<0x800000;i++);} {int i; for (i=0;i<0x800000;i++) asm("nop");}
/* wait for USB Vbus */ /* wait for USB Vbus */
while(gpio_get(GPIOA, GPIO8) == 0); while(gpio_get(GPIOA, GPIO8) == 0) asm("nop");
/* green LED on, connect USB */ /* green LED on, connect USB */
gpio_set(GPIOC, GPIO13); gpio_clear(GPIOC, GPIO2);
gpio_clear(GPIOC, GPIO15); gpio_set_mode(GPIOC, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOAT, GPIO15);
//gpio_clear(GPIOC, GPIO15);
while (1) while (1)
usbd_poll(); usbd_poll();