diff --git a/atusb/fw/board.h b/atusb/fw/board.h index 09ec915..bb0b2cc 100644 --- a/atusb/fw/board.h +++ b/atusb/fw/board.h @@ -1,8 +1,8 @@ /* * fw/board.h - Board-specific functions and definitions * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -13,6 +13,7 @@ #ifndef BOARD_H #define BOARD_H +#include #include @@ -87,7 +88,7 @@ void panic(void); uint64_t timer_read(void); void timer_init(void); -int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res); +bool gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res); void gpio_cleanup(void); void board_init(void); diff --git a/atusb/fw/board_app.c b/atusb/fw/board_app.c index d996593..a83b6c8 100644 --- a/atusb/fw/board_app.c +++ b/atusb/fw/board_app.c @@ -1,8 +1,8 @@ /* * fw/board_app.c - Board-specific functions (for the application) * - * Written 2011 by Werner Almesberger - * Copyright 2011 Werner Almesberger + * Written 2011, 2013 by Werner Almesberger + * Copyright 2011, 2013 Werner Almesberger * * 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 @@ -12,6 +12,7 @@ #include +#include #include #include @@ -92,7 +93,7 @@ void timer_init(void) } -int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res) +bool gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res) { EIMSK = 0; /* recover INT_RF to ATUSB_GPIO_CLEANUP or an MCU reset */ diff --git a/atusb/fw/ep0.c b/atusb/fw/ep0.c index 5bbe177..5c9fed4 100644 --- a/atusb/fw/ep0.c +++ b/atusb/fw/ep0.c @@ -1,8 +1,8 @@ /* * fw/ep0.c - EP0 extension protocol * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -11,6 +11,7 @@ */ +#include #include #include @@ -57,7 +58,7 @@ static void do_buf_write(void *user) #define BUILD_OFFSET 7 /* '#' plus "65535" plus ' ' */ -static int my_setup(const struct setup_request *setup) +static bool my_setup(const struct setup_request *setup) { uint16_t req = setup->bmRequestType | setup->bRequest << 8; unsigned tmp; @@ -254,7 +255,7 @@ static int my_setup(const struct setup_request *setup) } -static int my_dfu_setup(const struct setup_request *setup) +static bool my_dfu_setup(const struct setup_request *setup) { switch (setup->bmRequestType | setup->bRequest << 8) { case DFU_TO_DEV(DFU_DETACH): diff --git a/atusb/fw/flash.c b/atusb/fw/flash.c index 3aeea71..54d9a19 100644 --- a/atusb/fw/flash.c +++ b/atusb/fw/flash.c @@ -1,8 +1,8 @@ /* * fw/flash.c - Board-specific flash functions * - * Written 2011 by Werner Almesberger - * Copyright 2011 Werner Almesberger + * Written 2011, 2013 by Werner Almesberger + * Copyright 2011, 2013 Werner Almesberger * * 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 @@ -11,6 +11,7 @@ */ +#include #include #include @@ -29,7 +30,7 @@ void flash_start(void) } -int flash_can_write(uint16_t size) +bool flash_can_write(uint16_t size) { return payload+size <= BOOT_ADDR; } diff --git a/atusb/fw/mac.c b/atusb/fw/mac.c index ded7f96..9030dce 100644 --- a/atusb/fw/mac.c +++ b/atusb/fw/mac.c @@ -118,7 +118,7 @@ static void change_state(uint8_t new) } -int mac_rx(int on) +bool mac_rx(int on) { if (on) { mac_irq = handle_irq; @@ -178,7 +178,7 @@ static void do_tx(void *user) } -int mac_tx(uint16_t flags, uint16_t len) +bool mac_tx(uint16_t flags, uint16_t len) { if (len > MAX_PSDU) return 0; diff --git a/atusb/fw/mac.h b/atusb/fw/mac.h index b6eed97..6b06730 100644 --- a/atusb/fw/mac.h +++ b/atusb/fw/mac.h @@ -13,13 +13,14 @@ #ifndef MAC_H #define MAC_H +#include #include extern int (*mac_irq)(void); -int mac_rx(int on); -int mac_tx(uint16_t flags, uint16_t len); +bool mac_rx(int on); +bool mac_tx(uint16_t flags, uint16_t len); void mac_reset(void); #endif /* !MAC_H */ diff --git a/atusb/fw/sernum.c b/atusb/fw/sernum.c index e473d78..41e434c 100644 --- a/atusb/fw/sernum.c +++ b/atusb/fw/sernum.c @@ -1,8 +1,8 @@ /* * fw/sernum.c - ATUSB serial number * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -11,6 +11,7 @@ */ +#include #include #include "usb.h" @@ -26,7 +27,7 @@ static const uint8_t string_descriptor_0[] = { }; -int sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, +bool sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size) { if (type != USB_DT_STRING) diff --git a/atusb/fw/sernum.h b/atusb/fw/sernum.h index 1005618..31a8e27 100644 --- a/atusb/fw/sernum.h +++ b/atusb/fw/sernum.h @@ -1,8 +1,8 @@ /* * fw/sernum.h - ATUSB serial number * - * Written 2011 by Werner Almesberger - * Copyright 2011 Werner Almesberger + * Written 2011, 2013 by Werner Almesberger + * Copyright 2011, 2013 Werner Almesberger * * 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 @@ -13,6 +13,7 @@ #ifndef SERNUM_H #define SERNUM_H +#include #include #include "board.h" @@ -20,12 +21,12 @@ #ifdef HAS_BOARD_SERNUM -int sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, +bool sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size); #else /* HAS_BOARD_SERNUM */ -static inline int sernum_get_descr(uint8_t type, uint8_t index, +static inline bool sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size) { return 0; diff --git a/atusb/fw/spi.c b/atusb/fw/spi.c index 047523f..91a2de9 100644 --- a/atusb/fw/spi.c +++ b/atusb/fw/spi.c @@ -1,8 +1,8 @@ /* * fw/spi.c - ATmega8 family SPI I/O * - * Written 2011 by Werner Almesberger - * Copyright 2011 Werner Almesberger + * Written 2011, 2013 by Werner Almesberger + * Copyright 2011, 2013 Werner Almesberger * * 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 @@ -11,6 +11,7 @@ */ +#include #include #include @@ -19,7 +20,7 @@ #include "spi.h" -static int spi_initialized = 0; +static bool spi_initialized = 0; void spi_begin(void) diff --git a/atusb/fw/usb/atu2.c b/atusb/fw/usb/atu2.c index 5d078ae..17868a5 100644 --- a/atusb/fw/usb/atu2.c +++ b/atusb/fw/usb/atu2.c @@ -1,8 +1,8 @@ /* * fw/usb/atu2.c - Chip-specific driver for Atmel ATxxxU2 USB chips * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -18,6 +18,7 @@ * - enumeration often encounters an error -71 (from which it recovers) */ +#include #include #define F_CPU 8000000UL @@ -59,11 +60,10 @@ static void enable_addr(void *user) } -int set_addr(uint8_t addr) +void set_addr(uint8_t addr) { UDADDR = addr; usb_send(&eps[0], NULL, 0, enable_addr, NULL); - return 1; } @@ -76,7 +76,7 @@ void usb_ep_change(struct ep_descr *ep) } -static int ep_setup(void) +static bool ep_setup(void) { struct setup_request setup; @@ -96,7 +96,7 @@ static int ep_setup(void) } -static int ep_rx(struct ep_descr *ep) +static bool ep_rx(struct ep_descr *ep) { uint8_t size; diff --git a/atusb/fw/usb/dfu.c b/atusb/fw/usb/dfu.c index 83c52d5..996bac8 100644 --- a/atusb/fw/usb/dfu.c +++ b/atusb/fw/usb/dfu.c @@ -1,8 +1,8 @@ /* * boot/dfu.c - DFU protocol engine * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -25,6 +25,7 @@ */ +#include #include #include "usb.h" @@ -81,7 +82,7 @@ const uint8_t config_descriptor[] = { static uint16_t next_block = 0; -static int did_download; +static bool did_download; static uint8_t buf[EP0_SIZE]; @@ -95,7 +96,7 @@ static void block_write(void *user) } -static int block_receive(uint16_t length) +static bool block_receive(uint16_t length) { static uint16_t size; @@ -115,7 +116,7 @@ static int block_receive(uint16_t length) } -static int block_transmit(uint16_t length) +static bool block_transmit(uint16_t length) { uint16_t got; @@ -134,9 +135,9 @@ static int block_transmit(uint16_t length) } -static int my_setup(const struct setup_request *setup) +static bool my_setup(const struct setup_request *setup) { - int ok; + bool ok; switch (setup->bmRequestType | setup->bRequest << 8) { case DFU_TO_DEV(DFU_DETACH): diff --git a/atusb/fw/usb/dfu.h b/atusb/fw/usb/dfu.h index 691be2b..206a3c0 100644 --- a/atusb/fw/usb/dfu.h +++ b/atusb/fw/usb/dfu.h @@ -1,8 +1,8 @@ /* * boot/dfu.h - DFU protocol constants and data structures * - * Written 2008, 2011 by Werner Almesberger - * Copyright 2008, 2011 Werner Almesberger + * Written 2008, 2011, 2013 by Werner Almesberger + * Copyright 2008, 2011, 2013 Werner Almesberger * * 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 @@ -14,6 +14,7 @@ #ifndef DFU_H #define DFU_H +#include #include #include "usb.h" @@ -101,13 +102,13 @@ extern struct dfu dfu; void flash_start(void); -int flash_can_write(uint16_t size); +bool flash_can_write(uint16_t size); void flash_write(const uint8_t *buf, uint16_t size); void flash_end_write(void); uint16_t flash_read(uint8_t *buf, uint16_t size); -int dfu_setup_common(const struct setup_request *setup); -int dfu_my_descr(uint8_t type, uint8_t index, const uint8_t **reply, +bool dfu_setup_common(const struct setup_request *setup); +bool dfu_my_descr(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size); void dfu_init(void); diff --git a/atusb/fw/usb/dfu_common.c b/atusb/fw/usb/dfu_common.c index 6d025b0..a339c38 100644 --- a/atusb/fw/usb/dfu_common.c +++ b/atusb/fw/usb/dfu_common.c @@ -1,8 +1,8 @@ /* * boot/dfu_common.c - DFU protocol engine parts common to App/DFU * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -25,6 +25,7 @@ */ +#include #include #include "usb.h" @@ -65,7 +66,7 @@ struct dfu dfu = { }; -int dfu_setup_common(const struct setup_request *setup) +bool dfu_setup_common(const struct setup_request *setup) { switch (setup->bmRequestType | setup->bRequest << 8) { case DFU_FROM_DEV(DFU_GETSTATUS): @@ -89,7 +90,7 @@ int dfu_setup_common(const struct setup_request *setup) } -int dfu_my_descr(uint8_t type, uint8_t index, const uint8_t **reply, +bool dfu_my_descr(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size) { if (type != DFU_DT_FUNCTIONAL) diff --git a/atusb/fw/usb/usb.c b/atusb/fw/usb/usb.c index 3ab2688..4fde778 100644 --- a/atusb/fw/usb/usb.c +++ b/atusb/fw/usb/usb.c @@ -1,8 +1,8 @@ /* * fw/usb/usb.c - USB hardware setup and standard device requests * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -16,6 +16,7 @@ * - should support EP clearing and stalling */ +#include #include #include "usb.h" @@ -33,9 +34,9 @@ extern void panic(void); #define BUG_ON(cond) #endif -int (*user_setup)(const struct setup_request *setup); +bool (*user_setup)(const struct setup_request *setup); void (*user_set_interface)(int nth); -int (*user_get_descriptor)(uint8_t type, uint8_t index, +bool (*user_get_descriptor)(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size); void (*user_reset)(void); @@ -53,7 +54,7 @@ void usb_io(struct ep_descr *ep, enum ep_state state, uint8_t *buf, } -static int get_descriptor(uint8_t type, uint8_t index, uint16_t length) +static bool get_descriptor(uint8_t type, uint8_t index, uint16_t length) { const uint8_t *reply; uint8_t size; @@ -82,7 +83,7 @@ static int get_descriptor(uint8_t type, uint8_t index, uint16_t length) } -int handle_setup(const struct setup_request *setup) +bool handle_setup(const struct setup_request *setup) { switch (setup->bmRequestType | setup->bRequest << 8) { diff --git a/atusb/fw/usb/usb.h b/atusb/fw/usb/usb.h index f508091..90dd423 100644 --- a/atusb/fw/usb/usb.h +++ b/atusb/fw/usb/usb.h @@ -1,8 +1,8 @@ /* * fw/usb//usb.h - USB hardware setup and standard device requests * - * Written 2008, 2009, 2011 by Werner Almesberger - * Copyright 2008, 2009, 2011 Werner Almesberger + * Written 2008, 2009, 2011, 2013 by Werner Almesberger + * Copyright 2008, 2009, 2011, 2013 Werner Almesberger * * 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 @@ -15,6 +15,7 @@ #define USB_H +#include #include @@ -132,9 +133,9 @@ extern const uint8_t device_descriptor[]; extern const uint8_t config_descriptor[]; extern struct ep_descr eps[]; -extern int (*user_setup)(const struct setup_request *setup); +extern bool (*user_setup)(const struct setup_request *setup); extern void (*user_set_interface)(int nth); -extern int (*user_get_descriptor)(uint8_t type, uint8_t index, +extern bool (*user_get_descriptor)(uint8_t type, uint8_t index, const uint8_t **reply, uint8_t *size); extern void (*user_reset)(void); @@ -148,8 +149,8 @@ extern void (*user_reset)(void); void usb_io(struct ep_descr *ep, enum ep_state state, uint8_t *buf, uint8_t size, void (*callback)(void *user), void *user); -int handle_setup(const struct setup_request *setup); -int set_addr(uint8_t addr); +bool handle_setup(const struct setup_request *setup); +void set_addr(uint8_t addr); void usb_ep_change(struct ep_descr *ep); void usb_reset(void); void usb_init(void);