More build improvements and fixed broken examples.
This commit is contained in:
parent
08990e5243
commit
95286a22f0
5
Makefile
5
Makefile
@ -46,7 +46,7 @@ lib:
|
||||
done
|
||||
|
||||
examples:
|
||||
$(Q)for i in $(addsuffix /*,$(addprefix $@/,$(TARGETS))); do \
|
||||
$(Q)for i in $(addsuffix /*/*,$(addprefix $@/,$(TARGETS))); do \
|
||||
if [ -d $$i ]; then \
|
||||
printf " BUILD $$i\n"; \
|
||||
$(MAKE) -C $$i; \
|
||||
@ -65,8 +65,9 @@ install: lib
|
||||
|
||||
clean:
|
||||
$(Q)for i in $(addprefix lib/,$(TARGETS)) \
|
||||
$(addsuffix /*,$(addprefix examples/,$(TARGETS))); do \
|
||||
$(addsuffix /*/*,$(addprefix examples/,$(TARGETS))); do \
|
||||
if [ -d $$i ]; then \
|
||||
printf " CLEAN $$i\n"; \
|
||||
$(MAKE) -C $$i clean; \
|
||||
fi; \
|
||||
done
|
||||
|
@ -1,38 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: miniblink
|
||||
|
||||
miniblink:
|
||||
@printf " BUILD examples/lm3s/lm3s3748-evb/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/lm3s/lm3s3748-evb/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink clean
|
||||
|
||||
.PHONY: miniblink clean
|
||||
|
@ -1,38 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: miniblink
|
||||
|
||||
miniblink:
|
||||
@printf " BUILD examples/lpc13xx/lpc-p1343/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/lpc13xx/lpc-p1343/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink clean
|
||||
|
||||
.PHONY: miniblink clean
|
||||
|
@ -1,43 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
# TODO: Add usb_dfu later, doesn't build at the moment.
|
||||
all: fancyblink usb_hid
|
||||
|
||||
fancyblink:
|
||||
@printf " BUILD examples/stm32/lisa-m/fancyblink\n"
|
||||
$(Q)$(MAKE) -C usb_hid
|
||||
|
||||
usb_hid:
|
||||
@printf " BUILD examples/stm32/lisa-m/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/lisa-m/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid clean
|
||||
|
||||
.PHONY: fancyblink usb_hid clean
|
||||
|
@ -173,18 +173,26 @@ static void usbdfu_getstatus_complete(struct usb_setup_data *req)
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
static int usbdfu_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len, void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
if((req->bmRequestType & 0x7F) != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_DNLOAD:
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
if((len == NULL) || (*len == 0)) {
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
} else {
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = *len;
|
||||
memcpy(prog.buf, *buf, *len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
return 1;
|
||||
}
|
||||
case DFU_CLRSTATUS:
|
||||
/* Clear error and return to dfuIDLE */
|
||||
if(usbdfu_state == STATE_DFU_ERROR)
|
||||
@ -194,19 +202,6 @@ static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
/* Abort returns to dfuIDLE state */
|
||||
usbdfu_state = STATE_DFU_IDLE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
|
||||
if(req->bmRequestType != 0xA1)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_UPLOAD:
|
||||
/* Upload not supported for now */
|
||||
return 0;
|
||||
@ -235,26 +230,6 @@ static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_write(struct usb_setup_data *req, u8 *buf, u16 len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
if(req->bRequest != DFU_DNLOAD)
|
||||
return 0;
|
||||
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = len;
|
||||
memcpy(prog.buf, buf, len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
|
||||
@ -280,11 +255,12 @@ int main(void)
|
||||
AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON;
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
|
||||
|
||||
usbd_init(&dev, &config, usb_strings);
|
||||
usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings);
|
||||
usbd_set_control_buffer_size(sizeof(usbd_control_buffer));
|
||||
usbd_register_control_command_callback(usbdfu_control_command);
|
||||
usbd_register_control_write_callback(usbdfu_control_write);
|
||||
usbd_register_control_read_callback(usbdfu_control_read);
|
||||
usbd_register_control_callback(
|
||||
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
|
||||
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
|
||||
usbdfu_control_request);
|
||||
|
||||
gpio_set(GPIOA, GPIO15);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
|
@ -1,44 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: fancyblink pwmleds
|
||||
|
||||
fancyblink:
|
||||
@printf " BUILD examples/stm32/mb525/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink
|
||||
|
||||
pwmleds:
|
||||
@printf " BUILD examples/stm32/mb525/pwmleds\n"
|
||||
$(Q)$(MAKE) -C pwmleds
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/mb525/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink clean
|
||||
@printf " CLEAN examples/stm32/mb525/pwmleds\n"
|
||||
$(Q)$(MAKE) -C pwmleds clean
|
||||
|
||||
.PHONY: fancyblink pwmleds clean
|
||||
|
@ -1,56 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: led systick usart can
|
||||
|
||||
led:
|
||||
@printf " BUILD examples/stm32/obldc/led\n"
|
||||
$(Q)$(MAKE) -C led
|
||||
|
||||
systick:
|
||||
@printf " BUILD examples/stm32/obldc/systick\n"
|
||||
$(Q)$(MAKE) -C systick
|
||||
|
||||
usart:
|
||||
@printf " BUILD examples/stm32/obldc/usart\n"
|
||||
$(Q)$(MAKE) -C usart
|
||||
|
||||
can:
|
||||
@printf " BUILD examples/stm32/obldc/can\n"
|
||||
$(Q)$(MAKE) -C can
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/obldc/led\n"
|
||||
$(Q)$(MAKE) -C led clean
|
||||
@printf " CLEAN examples/stm32/obldc/systick\n"
|
||||
$(Q)$(MAKE) -C systick clean
|
||||
@printf " CLEAN examples/stm32/obldc/usart\n"
|
||||
$(Q)$(MAKE) -C usart clean
|
||||
@printf " CLEAN examples/stm32/obldc/can\n"
|
||||
$(Q)$(MAKE) -C can clean
|
||||
|
||||
.PHONY: led systick usart can
|
||||
|
@ -80,7 +80,7 @@ void usart1_isr(void)
|
||||
static u8 data = 'A';
|
||||
|
||||
/* Check if we were called because of RXNE. */
|
||||
if (((USART_CR1(USART1) & USART_SR_RXNEIE) != 0) &&
|
||||
if (((USART_CR1(USART1) & USART_CR1_RXNEIE) != 0) &&
|
||||
((USART_SR(USART1) & USART_SR_RXNE) != 0)) {
|
||||
/* Indicate that we got data. */
|
||||
gpio_toggle(GPIOA, GPIO6);
|
||||
@ -93,7 +93,7 @@ void usart1_isr(void)
|
||||
}
|
||||
|
||||
/* Check if we were called because of TXE. */
|
||||
if ((USART_CR1(USART1) & USART_SR_TXEIE) != 0) &&
|
||||
if (((USART_CR1(USART1) & USART_CR1_TXEIE) != 0) &&
|
||||
((USART_SR(USART1) & USART_SR_TXE) != 0)) {
|
||||
/* Indicate that we are sending out data. */
|
||||
gpio_toggle(GPIOA, GPIO7);
|
||||
|
@ -1,92 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick dogm128 rtc usb_cdcacm usb_dfu usb_hid
|
||||
|
||||
i2c_stts75_sensor:
|
||||
@printf " BUILD examples/stm32/other/i2c_stts75_sensor\n"
|
||||
$(Q)$(MAKE) -C i2c_stts75_sensor
|
||||
|
||||
adc_temperature_sensor:
|
||||
@printf " BUILD examples/stm32/other/adc_temperature_sensor\n"
|
||||
$(Q)$(MAKE) -C adc_temperature_sensor
|
||||
|
||||
dma_mem2mem:
|
||||
@printf " BUILD examples/stm32/other/dma_mem2mem\n"
|
||||
$(Q)$(MAKE) -C dma_mem2mem
|
||||
|
||||
timer_interrupt:
|
||||
@printf " BUILD examples/stm32/other/timer_interrupt\n"
|
||||
$(Q)$(MAKE) -C timer_interrupt
|
||||
|
||||
systick:
|
||||
@printf " BUILD examples/stm32/other/systick\n"
|
||||
$(Q)$(MAKE) -C systick
|
||||
|
||||
dogm128:
|
||||
@printf " BUILD examples/stm32/other/dogm128\n"
|
||||
$(Q)$(MAKE) -C dogm128
|
||||
|
||||
rtc:
|
||||
@printf " BUILD examples/stm32/other/rtc\n"
|
||||
$(Q)$(MAKE) -C rtc
|
||||
|
||||
usb_cdcacm:
|
||||
@printf " BUILD examples/stm32/other/usb_cdcacm\n"
|
||||
$(Q)$(MAKE) -C usb_cdcacm
|
||||
|
||||
usb_dfu:
|
||||
@printf " BUILD examples/stm32/other/usb_dfu\n"
|
||||
$(Q)$(MAKE) -C usb_dfu
|
||||
|
||||
usb_hid:
|
||||
@printf " BUILD examples/stm32/other/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/other/i2c_stts75_sensor\n"
|
||||
$(Q)$(MAKE) -C i2c_stts75_sensor clean
|
||||
@printf " CLEAN examples/stm32/other/adc_temperature_sensor\n"
|
||||
$(Q)$(MAKE) -C adc_temperature_sensor clean
|
||||
@printf " CLEAN examples/stm32/other/dma_mem2mem\n"
|
||||
$(Q)$(MAKE) -C dma_mem2mem clean
|
||||
@printf " CLEAN examples/stm32/other/timer_interrupt\n"
|
||||
$(Q)$(MAKE) -C timer_interrupt clean
|
||||
@printf " CLEAN examples/stm32/other/systick\n"
|
||||
$(Q)$(MAKE) -C systick clean
|
||||
@printf " CLEAN examples/stm32/other/dogm128\n"
|
||||
$(Q)$(MAKE) -C dogm128 clean
|
||||
@printf " CLEAN examples/stm32/other/rtc\n"
|
||||
$(Q)$(MAKE) -C rtc clean
|
||||
@printf " CLEAN examples/stm32/other/usb_cdcacm\n"
|
||||
$(Q)$(MAKE) -C usb_cdcacm clean
|
||||
@printf " CLEAN examples/stm32/other/usb_dfu\n"
|
||||
$(Q)$(MAKE) -C usb_dfu clean
|
||||
@printf " CLEAN examples/stm32/other/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid clean
|
||||
|
||||
.PHONY: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick dogm128 rtc clean usb_cdcacm usb_dfu usb_hid
|
||||
|
@ -1,62 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: miniblink fancyblink usart button rtc
|
||||
|
||||
miniblink:
|
||||
@printf " BUILD examples/stm32/stm32-discovery/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink
|
||||
|
||||
fancyblink:
|
||||
@printf " BUILD examples/stm32/stm32-discovery/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink
|
||||
|
||||
usart:
|
||||
@printf " BUILD examples/stm32/stm32-discovery/usart\n"
|
||||
$(Q)$(MAKE) -C usart
|
||||
|
||||
button:
|
||||
@printf " BUILD examples/stm32/stm32-discovery/button\n"
|
||||
$(Q)$(MAKE) -C button
|
||||
|
||||
rtc:
|
||||
@printf " BUILD examples/stm32/stm32-discovery/rtc\n"
|
||||
$(Q)$(MAKE) -C rtc
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/stm32-discovery/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink clean
|
||||
@printf " CLEAN examples/stm32/stm32-discovery/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink clean
|
||||
@printf " CLEAN examples/stm32/stm32-discovery/usart\n"
|
||||
$(Q)$(MAKE) -C usart clean
|
||||
@printf " CLEAN examples/stm32/stm32-discovery/button\n"
|
||||
$(Q)$(MAKE) -C button clean
|
||||
@printf " CLEAN examples/stm32/stm32-discovery/rtc\n"
|
||||
$(Q)$(MAKE) -C rtc clean
|
||||
|
||||
.PHONY: miniblink fancyblink usart button rtc clean
|
||||
|
@ -1,108 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: miniblink fancyblink usart usart_irq usart_printf usart_irq_printf timer usb_cdcacm usb_hid button exti_both traceswo
|
||||
|
||||
miniblink:
|
||||
@printf " BUILD examples/stm32/stm32-h103/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink
|
||||
|
||||
fancyblink:
|
||||
@printf " BUILD examples/stm32/stm32-h103/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink
|
||||
|
||||
usart:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usart\n"
|
||||
$(Q)$(MAKE) -C usart
|
||||
|
||||
usart_irq:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usart_irq\n"
|
||||
$(Q)$(MAKE) -C usart_irq
|
||||
|
||||
usart_printf:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usart_printf\n"
|
||||
$(Q)$(MAKE) -C usart_printf
|
||||
|
||||
usart_irq_printf:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usart_irq_printf\n"
|
||||
$(Q)$(MAKE) -C usart_irq_printf
|
||||
|
||||
timer:
|
||||
@printf " BUILD examples/stm32/stm32-h103/timer\n"
|
||||
$(Q)$(MAKE) -C timer
|
||||
|
||||
spi:
|
||||
@printf " BUILD examples/stm32/stm32-h103/spi\n"
|
||||
$(Q)$(MAKE) -C spi
|
||||
|
||||
usb_cdcacm:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usb_cdcacm\n"
|
||||
$(Q)$(MAKE) -C usb_cdcacm
|
||||
|
||||
usb_hid:
|
||||
@printf " BUILD examples/stm32/stm32-h103/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid
|
||||
|
||||
button:
|
||||
@printf " BUILD examples/stm32/stm32-h103/button\n"
|
||||
$(Q)$(MAKE) -C button
|
||||
|
||||
exti_both:
|
||||
@printf " BUILD examples/stm32/stm32-h103/exti_both\n"
|
||||
$(Q)$(MAKE) -C exti_both
|
||||
|
||||
traceswo:
|
||||
@printf " BUILD examples/stm32/stm32-h103/traceswo\n"
|
||||
$(Q)$(MAKE) -C traceswo
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/stm32-h103/miniblink\n"
|
||||
$(Q)$(MAKE) -C miniblink clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usart\n"
|
||||
$(Q)$(MAKE) -C usart clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usart_irq\n"
|
||||
$(Q)$(MAKE) -C usart_irq clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usart_printf\n"
|
||||
$(Q)$(MAKE) -C usart_printf clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usart_irq_printf\n"
|
||||
$(Q)$(MAKE) -C usart_irq_printf clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/spi\n"
|
||||
$(Q)$(MAKE) -C spi clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usb_cdcacm\n"
|
||||
$(Q)$(MAKE) -C usb_cdcacm clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/usb_hid\n"
|
||||
$(Q)$(MAKE) -C usb_hid clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/button\n"
|
||||
$(Q)$(MAKE) -C button clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/exti_both\n"
|
||||
$(Q)$(MAKE) -C exti_both clean
|
||||
@printf " CLEAN examples/stm32/stm32-h103/traceswo\n"
|
||||
$(Q)$(MAKE) -C traceswo clean
|
||||
|
||||
.PHONY: miniblink fancyblink usart usart_irq usart_printf usart_irq_printf timer spi usb_cdcacm usb_hid button exti_both traceswo clean
|
||||
|
@ -173,18 +173,26 @@ static void usbdfu_getstatus_complete(struct usb_setup_data *req)
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
static int usbdfu_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len, void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
if((req->bmRequestType & 0x7F) != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_DNLOAD:
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
if((len == NULL) || (*len == 0)) {
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
} else {
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = *len;
|
||||
memcpy(prog.buf, *buf, *len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
return 1;
|
||||
}
|
||||
case DFU_CLRSTATUS:
|
||||
/* Clear error and return to dfuIDLE */
|
||||
if(usbdfu_state == STATE_DFU_ERROR)
|
||||
@ -194,19 +202,6 @@ static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
/* Abort returns to dfuIDLE state */
|
||||
usbdfu_state = STATE_DFU_IDLE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
|
||||
if(req->bmRequestType != 0xA1)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_UPLOAD:
|
||||
/* Upload not supported for now */
|
||||
return 0;
|
||||
@ -235,26 +230,6 @@ static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_write(struct usb_setup_data *req, u8 *buf, u16 len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
if(req->bRequest != DFU_DNLOAD)
|
||||
return 0;
|
||||
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = len;
|
||||
memcpy(prog.buf, buf, len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
|
||||
@ -280,11 +255,12 @@ int main(void)
|
||||
AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON;
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
|
||||
|
||||
usbd_init(&dev, &config, usb_strings);
|
||||
usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings);
|
||||
usbd_set_control_buffer_size(sizeof(usbd_control_buffer));
|
||||
usbd_register_control_command_callback(usbdfu_control_command);
|
||||
usbd_register_control_write_callback(usbdfu_control_write);
|
||||
usbd_register_control_read_callback(usbdfu_control_read);
|
||||
usbd_register_control_callback(
|
||||
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
|
||||
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
|
||||
usbdfu_control_request);
|
||||
|
||||
gpio_set(GPIOA, GPIO15);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
|
@ -19,5 +19,5 @@
|
||||
|
||||
BINARY = usbiap
|
||||
|
||||
include ../../Makefile.includes
|
||||
include ../../Makefile.include
|
||||
|
||||
|
@ -173,18 +173,26 @@ static void usbdfu_getstatus_complete(struct usb_setup_data *req)
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
static int usbdfu_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len, void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
if((req->bmRequestType & 0x7F) != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_DNLOAD:
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
if((len == NULL) || (*len == 0)) {
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
} else {
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = *len;
|
||||
memcpy(prog.buf, *buf, *len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
return 1;
|
||||
}
|
||||
case DFU_CLRSTATUS:
|
||||
/* Clear error and return to dfuIDLE */
|
||||
if(usbdfu_state == STATE_DFU_ERROR)
|
||||
@ -194,19 +202,6 @@ static int usbdfu_control_command(struct usb_setup_data *req,
|
||||
/* Abort returns to dfuIDLE state */
|
||||
usbdfu_state = STATE_DFU_IDLE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
|
||||
if(req->bmRequestType != 0xA1)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_UPLOAD:
|
||||
/* Upload not supported for now */
|
||||
return 0;
|
||||
@ -235,26 +230,6 @@ static int usbdfu_control_read(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbdfu_control_write(struct usb_setup_data *req, u8 *buf, u16 len,
|
||||
void (**complete)(struct usb_setup_data *req))
|
||||
{
|
||||
(void)complete;
|
||||
|
||||
if(req->bmRequestType != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
|
||||
if(req->bRequest != DFU_DNLOAD)
|
||||
return 0;
|
||||
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
prog.len = len;
|
||||
memcpy(prog.buf, buf, len);
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
|
||||
@ -280,11 +255,12 @@ int main(void)
|
||||
AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON;
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15);
|
||||
|
||||
usbd_init(&dev, &config, usb_strings);
|
||||
usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings);
|
||||
usbd_set_control_buffer_size(sizeof(usbd_control_buffer));
|
||||
usbd_register_control_command_callback(usbdfu_control_command);
|
||||
usbd_register_control_write_callback(usbdfu_control_write);
|
||||
usbd_register_control_read_callback(usbdfu_control_read);
|
||||
usbd_register_control_callback(
|
||||
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
|
||||
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
|
||||
usbdfu_control_request);
|
||||
|
||||
gpio_set(GPIOA, GPIO15);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
|
@ -1,38 +0,0 @@
|
||||
##
|
||||
## This file is part of the libopencm3 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## 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
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
# Do not print "Entering directory ...".
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: fancyblink
|
||||
|
||||
fancyblink:
|
||||
@printf " BUILD examples/stm32/stm32-h107/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/stm32/stm32-h107/fancyblink\n"
|
||||
$(Q)$(MAKE) -C fancyblink clean
|
||||
|
||||
.PHONY: fancyblink
|
||||
|
Loading…
x
Reference in New Issue
Block a user