Skip to content

Commit

Permalink
Update to the current latest version of locm3
Browse files Browse the repository at this point in the history
can: remove the can port parameter from can_filter_xxx calls
usb: use enum_usbd_request_return_codes instead of int for usb callbacks
usart: use commonalized f0/f1 usart definitions
  • Loading branch information
devanlai committed Oct 4, 2018
1 parent c5eecdc commit 5d23d23
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 105 deletions.
2 changes: 1 addition & 1 deletion libopencm3
Submodule libopencm3 updated 620 files
3 changes: 1 addition & 2 deletions src/CAN/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ bool can_reconfigure(uint32_t baudrate, CanMode mode) {
silent) != 0) {
return false;
} else {
can_filter_id_mask_32bit_init(CAN1,
0, /* Filter ID */
can_filter_id_mask_32bit_init(0, /* Filter ID */
0, /* CAN ID */
0, /* CAN ID mask */
0, /* FIFO assignment (here: FIFO0) */
Expand Down
11 changes: 6 additions & 5 deletions src/USB/cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ bool cdc_send_data(const uint8_t* data, size_t len) {
return (sent != 0);
}

static int cdc_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
cdc_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
(void)complete;
(void)usbd_dev;

if (req->wIndex != INTF_CDC_DATA && req->wIndex != INTF_CDC_COMM) {
return USBD_REQ_NEXT_CALLBACK;
}
int status = USBD_REQ_NOTSUPP;
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;

switch (req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
Expand Down
11 changes: 6 additions & 5 deletions src/USB/composite_usb_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,13 @@ void cmp_usb_register_control_class_callback(uint16_t interface,
}
}

static int cmp_usb_dispatch_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
cmp_usb_dispatch_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {

int result = USBD_REQ_NEXT_CALLBACK;
enum usbd_request_return_codes result = USBD_REQ_NEXT_CALLBACK;

uint8_t i;
uint16_t interface = req->wIndex;
Expand Down
11 changes: 6 additions & 5 deletions src/USB/dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const struct usb_dfu_descriptor dfu_function = {
/* User callbacks */
static GenericCallback dfu_detach_request_callback = NULL;

static int dfu_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
dfu_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
(void)complete;
(void)buf;
(void)len;
Expand All @@ -50,7 +51,7 @@ static int dfu_control_class_request(usbd_device *usbd_dev,
return USBD_REQ_NEXT_CALLBACK;
}

int status = USBD_REQ_NOTSUPP;
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;
switch (req->bRequest) {
case DFU_DETACH: {
if (dfu_detach_request_callback != NULL) {
Expand Down
20 changes: 11 additions & 9 deletions src/USB/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ static HostInFunction hid_report_in_callback = NULL;

static usbd_device* hid_usbd_dev = NULL;

static int hid_control_standard_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
hid_control_standard_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
(void)complete;
(void)usbd_dev;

Expand Down Expand Up @@ -103,18 +104,19 @@ static int hid_control_standard_request(usbd_device *usbd_dev,
return status;
}

static int hid_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
hid_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
(void)complete;
(void)usbd_dev;

if (req->wIndex != INTF_HID) {
return USBD_REQ_NEXT_CALLBACK;
}

int status = USBD_REQ_NOTSUPP;
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;
switch (req->bRequest) {
case USB_HID_REQ_GET_REPORT: {
if ((hid_report_in_callback != NULL) && (*buf != NULL)) {
Expand Down
11 changes: 6 additions & 5 deletions src/USB/vcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ size_t vcdc_send_buffer_space(void) {
static GenericCallback vcdc_rx_callback = NULL;
static GenericCallback vcdc_tx_callback = NULL;

static int vcdc_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
static enum usbd_request_return_codes
vcdc_control_class_request(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len,
usbd_control_complete_callback* complete) {
(void)complete;
(void)usbd_dev;
(void)buf;
Expand All @@ -154,7 +155,7 @@ static int vcdc_control_class_request(usbd_device *usbd_dev,
if (req->wIndex != INTF_VCDC_DATA && req->wIndex != INTF_VCDC_COMM) {
return USBD_REQ_NEXT_CALLBACK;
}
int status = USBD_REQ_NOTSUPP;
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;

switch (req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
Expand Down
3 changes: 2 additions & 1 deletion src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/dma.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/usart.h>

#include "console.h"
#include "target.h"
Expand Down Expand Up @@ -205,7 +206,7 @@ uint8_t console_recv_blocking(void) {
}

void CONSOLE_USART_IRQ_NAME(void) {
if (usart_get_flag(CONSOLE_USART, USART_SR_TXE)) {
if (usart_get_flag(CONSOLE_USART, USART_FLAG_TXE)) {
if (!console_tx_buffer_empty()) {
usart_word_t buffered_byte = console_tx_buffer_get();
usart_send(CONSOLE_USART, buffered_byte);
Expand Down
18 changes: 0 additions & 18 deletions src/stm32f042/brain3.3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,6 @@
#define SOFT_DFU_GPIO_PIN GPIO4
#define SOFT_DFU_ACTIVE_HIGH 0

#include <libopencm3/stm32/usart.h>
/* Workaround for non-commonalized STM32F0 USART code */
#ifndef USART_STOPBITS_1
#define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT
#endif

#ifndef USART_STOPBITS_2
#define USART_STOPBITS_2 USART_CR2_STOP_2_0BIT
#endif

#ifndef USART_SR_RXNE
#define USART_SR_RXNE USART_ISR_RXNE
#endif

#ifndef USART_SR_TXE
#define USART_SR_TXE USART_ISR_TXE
#endif

/* Word size for usart_recv and usart_send */
typedef uint8_t usart_word_t;

Expand Down
18 changes: 0 additions & 18 deletions src/stm32f042/dap42/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@
#define nBOOT0_GPIO_PORT GPIOB
#define nBOOT0_GPIO_PIN GPIO8

#include <libopencm3/stm32/usart.h>
/* Workaround for non-commonalized STM32F0 USART code */
#ifndef USART_STOPBITS_1
#define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT
#endif

#ifndef USART_STOPBITS_2
#define USART_STOPBITS_2 USART_CR2_STOP_2_0BIT
#endif

#ifndef USART_SR_RXNE
#define USART_SR_RXNE USART_ISR_RXNE
#endif

#ifndef USART_SR_TXE
#define USART_SR_TXE USART_ISR_TXE
#endif

/* Word size for usart_recv and usart_send */
typedef uint8_t usart_word_t;

Expand Down
18 changes: 0 additions & 18 deletions src/stm32f042/dap42k6u/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@
#define nBOOT0_GPIO_PORT GPIOF
#define nBOOT0_GPIO_PIN GPIO11

#include <libopencm3/stm32/usart.h>
/* Workaround for non-commonalized STM32F0 USART code */
#ifndef USART_STOPBITS_1
#define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT
#endif

#ifndef USART_STOPBITS_2
#define USART_STOPBITS_2 USART_CR2_STOP_2_0BIT
#endif

#ifndef USART_SR_RXNE
#define USART_SR_RXNE USART_ISR_RXNE
#endif

#ifndef USART_SR_TXE
#define USART_SR_TXE USART_ISR_TXE
#endif

/* Word size for usart_recv and usart_send */
typedef uint8_t usart_word_t;

Expand Down
18 changes: 0 additions & 18 deletions src/stm32f042/kitchen42/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@
#define nBOOT0_GPIO_PORT GPIOF
#define nBOOT0_GPIO_PIN GPIO11

#include <libopencm3/stm32/usart.h>
/* Workaround for non-commonalized STM32F0 USART code */
#ifndef USART_STOPBITS_1
#define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT
#endif

#ifndef USART_STOPBITS_2
#define USART_STOPBITS_2 USART_CR2_STOP_2_0BIT
#endif

#ifndef USART_SR_RXNE
#define USART_SR_RXNE USART_ISR_RXNE
#endif

#ifndef USART_SR_TXE
#define USART_SR_TXE USART_ISR_TXE
#endif

/* Word size for usart_recv and usart_send */
typedef uint8_t usart_word_t;

Expand Down

0 comments on commit 5d23d23

Please sign in to comment.