Skip to content

Commit

Permalink
update submodules and Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
dword1511 committed Jul 17, 2018
1 parent 7023619 commit 3bd6658
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
37 changes: 21 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy
OBJDUMP = $(CROSS)objdump
SIZE = $(CROSS)size
NM = $(CROSS)nm

ELF = $(PROGRAM).elf
BIN = $(PROGRAM).bin
Expand All @@ -42,23 +43,23 @@ endif

all:
ifndef BOARD
@echo "Please specify a board by using 'make BOARD=board'."
@echo "Please specify a board by using '$(MAKE) BOARD=board'."
@echo "Available boards:"
@echo "===================="
@ls boards/*.h | cut -d '/' -f 2 | cut -d '.' -f 1
else
ifndef LAST_BOARD
@echo "First run, cleaning..."
@make clean
@$(MAKE) clean
else
ifneq ($(LAST_BOARD), $(BOARD))
@echo "Board changed, cleaning..."
@make clean
@$(MAKE) clean
endif
endif
@echo "LAST_BOARD = $(BOARD)" > last_board.mk
@ln -sfT "boards/$(BOARD).h" board.h
@make firmware
@$(MAKE) firmware
endif

CFLAGS += -O3 -Wall -g -std=gnu99
Expand All @@ -77,10 +78,13 @@ LDPATH = libopencm3/lib/
LDFLAGS += -L$(LDPATH) -T$(LDSCRIPT) -Map $(MAP) --gc-sections
LDLIBS += $(LIBOPENCM3) $(LIBC) $(LIBGCC)

firmware: $(LIBOPENCM3) $(BIN) $(HEX) $(DMP) size

.PHONY: firmware docs clean distclean flash flash-dfu reboot size symbols test

firmware: $(BIN) $(HEX) $(DMP) size
docs: $(DOCS)

$(ELF): $(LDSCRIPT) $(OBJS)
$(ELF): $(LDSCRIPT) $(OBJS) $(LIBOPENCM3)
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LDLIBS)

$(DMP): $(ELF)
Expand All @@ -92,31 +96,28 @@ $(DMP): $(ELF)
%.bin: %.elf
$(OBJCOPY) -S -O binary $< $@

%.o: %.c board.h
%.o: %.c board.h $(LIBOPENCM3)
$(CC) $(CFLAGS) -c $< -o $@

%.html: %.md
markdown $< > $@

$(LIBOPENCM3):
git submodule init
git submodule update --remote
CFLAGS="$(CFLAGS)" make -C libopencm3 $(OPENCM3_MK) V=1
git submodule update --init
CFLAGS="$(CFLAGS)" $(MAKE) -C libopencm3 $(OPENCM3_MK) V=1

flashrom/flashrom:
git submodule init
git submodule update --remote
make -C flashrom


.PHONY: clean distclean flash flash-dfu reboot size test
git submodule update --init
$(MAKE) -C flashrom

clean:
rm -f $(OBJS) $(DOCS) $(ELF) $(HEX) $(BIN) $(MAP) $(DMP) board.h last_board.mk

distclean: clean
make -C libopencm3 clean
make -C flashrom distclean
$(MAKE) -C libopencm3 clean
$(MAKE) -C flashrom distclean
rm -f *~ *.swp *.hex *.bin

flash: $(HEX)
Expand All @@ -133,6 +134,10 @@ size: $(PROGRAM).elf
@$(SIZE) $(PROGRAM).elf
@echo ""

symbols: $(ELF)
@$(NM) --demangle --size-sort -S $< | grep -v ' [bB] '


# Erasing must come first, otherwise some sectors might be skipped.
# After testing you may clear flash contents manually.
test: flashrom/flashrom
Expand Down
2 changes: 1 addition & 1 deletion flashrom
Submodule flashrom updated from 1da60f to b2154e
2 changes: 1 addition & 1 deletion libopencm3
Submodule libopencm3 updated 465 files
3 changes: 1 addition & 2 deletions spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ uint32_t spi_setup(uint32_t speed_hz) {
* Frame format: MSB First
*/
#ifdef STM32F0
spi_init_master(SPI1, clkdiv, SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE, SPI_CR1_CPHA_CLK_TRANSITION_1, SPI_CR1_CRCL_8BIT, SPI_CR1_MSBFIRST);
spi_init_master(SPI1, clkdiv, SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE, SPI_CR1_CPHA_CLK_TRANSITION_1, SPI_CR1_MSBFIRST);
spi_set_data_size(SPI1, SPI_CR2_DS_8BIT);
spi_fifo_reception_threshold_8bit(SPI1);
spi_i2s_mode_spi_mode(SPI1);
#else
spi_init_master(SPI1, clkdiv, SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE, SPI_CR1_CPHA_CLK_TRANSITION_1, SPI_CR1_DFF_8BIT, SPI_CR1_MSBFIRST);
#endif /* STM32F0 */
Expand Down
10 changes: 5 additions & 5 deletions usbcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static const struct usb_config_descriptor config = {
/* Buffer to be used for control requests. */
static uint8_t usbd_control_buffer[128];

static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
static enum usbd_request_return_codes cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req)) {
switch (req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
Expand All @@ -177,14 +177,14 @@ static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *
notif->wLength = 2;
local_buf[8] = req->wValue & 3;
local_buf[9] = 0;
return 1;
return USBD_REQ_HANDLED;
}
case USB_CDC_REQ_SET_LINE_CODING:
if (*len < sizeof(struct usb_cdc_line_coding))
return 0;
return 1;
return USBD_REQ_NOTSUPP;
return USBD_REQ_HANDLED;
}
return 0;
return USBD_REQ_NOTSUPP;
}

volatile bool usb_ready = false;
Expand Down

0 comments on commit 3bd6658

Please sign in to comment.