#include "conf_usb.h"
#include "board.h"
#include "usb_drv.h"
#include "gpio.h"
#include "pdca.h"
#include "intc.h"
#include "usart.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "cycle_counter.h"
#include "fifo.h"
#include "power_clocks_lib.h"
#include "qtouch_debug_frame.h"
#include "device_hid_qtouch_debug_task.h"
#include <string.h>
Macros | |
#define | AVR32_PDCA_PID_USART_TX AVR32_PDCA_PID_USART1_TX |
#define | PDCA_CHANNEL_USART 0 |
#define | RX_LED AVR32_PIN_PA20 |
#define | TX_LED AVR32_PIN_PA21 |
#define | USART (&AVR32_USART1) |
#define | USART_BAUDRATE 115200 |
#define | USART_IRQ AVR32_USART1_IRQ |
#define | USART_RX_BUFFER (EP_IN_LENGTH*2) |
#define | USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
#define | USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
#define | USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
#define | USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
Functions | |
void | device_generic_hid_task (void) |
Entry point of the HID generic communication task This function manages IN/OUT report management. More... | |
void | device_generic_hid_task_init (void) |
This function initializes the hardware/software resources required for device generic HID task. More... | |
void | fill_tx_buffer (void) |
Send data report to USB HID Host. More... | |
void | hid_check_vbus (void) |
check if USB VBUS active. More... | |
static void | hid_report_in (void) |
Send data report to USB HID Host. More... | |
static void | hid_report_out (void) |
Get data report from Host. More... | |
void | init_rs232 (unsigned long baudrate, long pba_hz) |
This function initializes USART connected to main UC3 device present on the kit. More... | |
static void | int_handler_usart (void) |
void | usb_sof_action (void) |
usb_sof_action More... | |
void | usb_write_message (void *ptr_cram) |
Write message to USB HID Host. More... | |
Variables | |
static struct hid_frames | ack_message |
static fifo_desc_t | fifo_desc_usart |
static uint8_t | fifo_rx [USART_RX_BUFFER] |
int | jump_bootloader |
struct hid_frames | out_buffer |
pcl_freq_param_t | pcl_freq_param |
static int | recieved_data =0 |
static bool | send_ack = false |
static bool | send_nack = false |
static U16 | sof_cnt |
static bool | write_hid_message = false |
static int | write_hid_message_index =0 |
#define AVR32_PDCA_PID_USART_TX AVR32_PDCA_PID_USART1_TX |
Referenced by device_generic_hid_task_init().
#define PDCA_CHANNEL_USART 0 |
Referenced by device_generic_hid_task_init(), hid_report_in(), and hid_report_out().
#define RX_LED AVR32_PIN_PA20 |
Referenced by device_generic_hid_task_init(), fill_tx_buffer(), hid_check_vbus(), hid_report_out(), and int_handler_usart().
#define TX_LED AVR32_PIN_PA21 |
Referenced by device_generic_hid_task_init(), fill_tx_buffer(), hid_check_vbus(), hid_report_in(), and int_handler_usart().
#define USART (&AVR32_USART1) |
Referenced by hid_check_vbus(), init_rs232(), and int_handler_usart().
#define USART_BAUDRATE 115200 |
Referenced by hid_check_vbus().
#define USART_IRQ AVR32_USART1_IRQ |
Referenced by device_generic_hid_task_init().
#define USART_RX_BUFFER (EP_IN_LENGTH*2) |
Referenced by device_generic_hid_task_init().
#define USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
Referenced by init_rs232().
#define USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
Referenced by hid_check_vbus(), and init_rs232().
#define USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
Referenced by init_rs232().
#define USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
Referenced by init_rs232().
void device_generic_hid_task | ( | void | ) |
Entry point of the HID generic communication task This function manages IN/OUT report management.
References fill_tx_buffer(), hid_check_vbus(), hid_report_in(), hid_report_out(), and Is_device_enumerated.
Referenced by main().
void device_generic_hid_task_init | ( | void | ) |
This function initializes the hardware/software resources required for device generic HID task.
References ack_message, pdca_channel_options_t::addr, AVR32_PDCA_PID_USART_TX, Disable_global_interrupt, Enable_global_interrupt, fifo_init(), fifo_rx, gpio_set_gpio_pin(), int_handler_usart(), INTC_register_interrupt(), Is_usb_device, hid_frames::packetCount, hid_frames::packetNumber, hid_frames::payload, PAYLOAD_SIZE, PDCA_CHANNEL_USART, pdca_init_channel(), PDCA_TRANSFER_SIZE_BYTE, PROTOCOL_ID, hid_frames::protocol_id, RX_LED, serial_tx_frame, sof_cnt, hid_frames::spare_byte1, hid_frames::spare_byte2, TX_LED, USART_IRQ, USART_RX_BUFFER, and Usb_enable_sof_interrupt.
Referenced by main().
void fill_tx_buffer | ( | void | ) |
Send data report to USB HID Host.
References fifo_get_used_size(), FIFO_OK, fifo_pull_uint8(), gpio_clr_gpio_pin(), recieved_data, RX_LED, send_message(), serial_rx_frame, TX_LED, write_hid_message, and write_hid_message_index.
Referenced by device_generic_hid_task().
void hid_check_vbus | ( | void | ) |
check if USB VBUS active.
If VBUS is not active, put the device in Stop mode until VBUS become active
References cpu_delay_ms(), FOSC0, gpio_clr_gpio_pin(), gpio_enable_pin_pull_up(), gpio_set_gpio_pin(), gpio_tgl_gpio_pin(), init_rs232(), Is_usb_vbus_low, pcl_freq_param, RX_LED, SLEEP, TX_LED, USART, USART_BAUDRATE, and USART_RX_PIN.
Referenced by device_generic_hid_task().
|
static |
Send data report to USB HID Host.
References ACK_MESSAGE, ack_message, EP_HID_GENERIC_IN, gpio_tgl_gpio_pin(), hid_rx_frame, Is_usb_write_enabled, NACK_MESSAGE, hid_frames::packetCount, hid_frames::packetNumber, PDCA_CHANNEL_USART, pdca_get_transfer_status(), PDCA_TRANSFER_COMPLETE, recieved_data, send_ack, send_nack, hid_frames::spare_byte2, TX_LED, usb_write_message(), write_hid_message, and write_hid_message_index.
Referenced by device_generic_hid_task().
|
static |
Get data report from Host.
References cpu_delay_ms(), EP_HID_GENERIC_OUT, EP_OUT_LENGTH, get_message(), gpio_set_gpio_pin(), gpio_tgl_gpio_pin(), Is_usb_out_received, jump_bootloader, LED0_GPIO, LED1_GPIO, LED2_GPIO, LED3_GPIO, MESSAGE_READY, out_buffer, hid_frames::packetCount, pcl_freq_param, PDCA_CHANNEL_USART, pdca_enable(), pdca_get_transfer_status(), pdca_load_channel(), PDCA_TRANSFER_COMPLETE, RX_LED, send_ack, send_nack, serial_tx_frame, SLEEP, Usb_ack_out_received_free, Usb_detach, usb_read_ep_rxpacket(), and Usb_reset_endpoint_fifo_access.
Referenced by device_generic_hid_task().
void init_rs232 | ( | unsigned long | baudrate, |
long | pba_hz | ||
) |
This function initializes USART connected to main UC3 device present on the kit.
References usart_options_t::baudrate, gpio_enable_module(), USART, USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, USART_NORMAL_CHMODE, USART_RX_FUNCTION, USART_RX_PIN, USART_TX_FUNCTION, and USART_TX_PIN.
Referenced by hid_check_vbus().
|
static |
References FIFO_ERROR_OVERFLOW, fifo_push_uint8(), gpio_clr_gpio_pin(), RX_LED, TX_LED, and USART.
Referenced by device_generic_hid_task_init().
void usb_write_message | ( | void * | ptr_cram | ) |
Write message to USB HID Host.
References data_to_transfer, EP_HID_GENERIC_IN, EP_IN_LENGTH, Is_usb_in_ready, Usb_ack_in_ready_send, Usb_reset_endpoint_fifo_access, and usb_write_ep_txpacket().
Referenced by hid_report_in().
|
static |
Referenced by device_generic_hid_task_init(), and hid_report_in().
|
static |
|
static |
Referenced by device_generic_hid_task_init().
int jump_bootloader |
Referenced by hid_report_out(), and usb_hid_set_report_feature().
struct hid_frames out_buffer |
Referenced by hid_report_out().
pcl_freq_param_t pcl_freq_param |
Referenced by hid_check_vbus(), hid_report_out(), and main().
|
static |
Referenced by fill_tx_buffer(), and hid_report_in().
Referenced by hid_report_in(), and hid_report_out().
Referenced by hid_report_in(), and hid_report_out().
|
static |
Referenced by device_generic_hid_task_init(), and usb_sof_action().
Referenced by fill_tx_buffer(), and hid_report_in().
|
static |
Referenced by fill_tx_buffer(), and hid_report_in().