Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/pio_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
* Copyright (c) 2021 sekigon-gonnoc
*/

#pragma GCC push_options
#pragma GCC optimize("-O3")

#include <stdio.h>
#include <stdint.h>
#include <string.h> // memcpy
Expand All @@ -26,6 +23,9 @@
#include "usb_tx.pio.h"
#include "usb_rx.pio.h"

GCC_Pragma("GCC push_options")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note, i don't know if we actually need O3 on LLVM, if so we may need a different Clang_Pragma

GCC_Pragma("GCC optimize(\"O3\")")

#define UNUSED_PARAMETER(x) (void)x

usb_device_t pio_usb_device[PIO_USB_DEVICE_CNT];
Expand Down Expand Up @@ -470,7 +470,7 @@ uint8_t __no_inline_not_in_flash_func(pio_usb_ll_encode_tx_data)(
return byte_idx;
}

static inline __force_inline void prepare_tx_data(endpoint_t *ep) {
static __force_inline void prepare_tx_data(endpoint_t *ep) {
uint16_t const xact_len = pio_usb_ll_get_transaction_len(ep);
uint8_t buffer[PIO_USB_EP_SIZE + 4];
buffer[0] = USB_SYNC;
Expand Down Expand Up @@ -583,4 +583,5 @@ int pio_usb_host_add_port(uint8_t pin_dp, PIO_USB_PINOUT pinout) {
return -1;
}

#pragma GCC pop_options
GCC_Pragma("GCC pop_options")

8 changes: 4 additions & 4 deletions src/pio_usb_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* Ha Thach ([email protected])
*/

#pragma GCC push_options
#pragma GCC optimize("-O3")

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Expand All @@ -23,6 +20,9 @@
#include "hardware/gpio.h"
#include "hardware/pio.h"

GCC_Pragma("GCC push_options")
GCC_Pragma("GCC optimize(\"O3\")")

static uint8_t new_devaddr = 0;
static uint8_t ep0_crc5_lut[16];
static __unused usb_descriptor_buffers_t descriptor_buffers;
Expand Down Expand Up @@ -567,4 +567,4 @@ static void __no_inline_not_in_flash_func(__pio_usb_device_irq_handler)(uint8_t
// weak alias to __pio_usb_device_irq_handler
void pio_usb_device_irq_handler(uint8_t root_id) __attribute__ ((weak, alias("__pio_usb_device_irq_handler")));

#pragma GCC pop_options
GCC_Pragma("GCC pop_options")
11 changes: 6 additions & 5 deletions src/pio_usb_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* Ha Thach ([email protected])
*/

#pragma GCC push_options
#pragma GCC optimize("-O3")

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Expand All @@ -21,6 +18,9 @@
#include "usb_rx.pio.h"
#include "usb_tx.pio.h"

GCC_Pragma("GCC push_options")
GCC_Pragma("GCC optimize(\"O3\")")

static alarm_pool_t *_alarm_pool = NULL;
static repeating_timer_t sof_rt;
// The sof_count may be incremented and then read on different cores.
Expand Down Expand Up @@ -401,7 +401,7 @@ void pio_usb_host_close_device(uint8_t root_idx, uint8_t device_address) {
}
}

static inline __force_inline endpoint_t * _find_ep(uint8_t root_idx,
static __force_inline endpoint_t * _find_ep(uint8_t root_idx,
uint8_t device_address, uint8_t ep_address) {
for (int ep_pool_idx = 0; ep_pool_idx < PIO_USB_EP_POOL_CNT; ep_pool_idx++) {
endpoint_t *ep = PIO_USB_ENDPOINT(ep_pool_idx);
Expand Down Expand Up @@ -1367,4 +1367,5 @@ static void __no_inline_not_in_flash_func(__pio_usb_host_irq_handler)(uint8_t ro
// weak alias to __pio_usb_host_irq_handler
void pio_usb_host_irq_handler(uint8_t root_id) __attribute__ ((weak, alias("__pio_usb_host_irq_handler")));

#pragma GCC pop_options
GCC_Pragma("GCC pop_options")

4 changes: 2 additions & 2 deletions src/pio_usb_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool pio_usb_ll_transfer_start(endpoint_t *ep, uint8_t *buffer,
bool pio_usb_ll_transfer_continue(endpoint_t *ep, uint16_t xferred_bytes);
void pio_usb_ll_transfer_complete(endpoint_t *ep, uint32_t flag);

static inline __force_inline uint16_t
static __force_inline uint16_t
pio_usb_ll_get_transaction_len(endpoint_t *ep) {
uint16_t remaining = ep->total_len - ep->actual_len;
return (remaining < ep->size) ? remaining : ep->size;
Expand Down Expand Up @@ -203,7 +203,7 @@ bool pio_usb_device_endpoint_open(uint8_t const *desc_endpoint);
bool pio_usb_device_transfer(uint8_t ep_address, uint8_t *buffer,
uint16_t buflen);

static inline __force_inline endpoint_t *
static __force_inline endpoint_t *
pio_usb_device_get_endpoint_by_address(uint8_t ep_address) {
// index = 2*num + dir e.g out1, in1, out2, in2
uint8_t const ep_idx = ((ep_address & 0x7f) << 1) | (ep_address >> 7);
Expand Down