USB FIFO access. More...
#include "xpal_board.h"Go to the source code of this file.
Data Structures | |
| struct | USB_statistics_s |
| USB I/O statistics. More... | |
Defines | |
| #define | USB_FLAG_NONBLOCK (0x01) |
| set non-blocking behaviour for USB FIFO functions | |
Typedefs | |
| typedef uint8_t | USB_flags_t |
| typedef struct USB_statistics_s | USB_statistics_t |
| USB I/O statistics. | |
Enumerations | |
| enum | USB_stream_sel_t { USB_STDIN, USB_STDOUT } |
selector IN/OUT for USB_set_block_flags() | |
| enum | USB_flag_action_t { USB_flag_clear = 0, USB_flag_toggle = 1, USB_flag_set = 2, USB_flag_assign = 3 } |
action for USB_set_block_flags() | |
Functions | |
| void | USBInit (void) |
| initialize USB interface | |
| void | USB_assign_stdio (void) |
| assign USB interface to stdio streams | |
| uint8_t | USB_rx_ready (void) |
| check if at least one byte is in USB rx FIFO, i.e. the next read from USB will not block | |
| int8_t | USB_set_flags (USB_stream_sel_t usb_stream, USB_flag_action_t action, USB_flags_t flags) |
| set blocking/non-blocking characteristic for USB FIFO | |
| int8_t | USB_get_flags (USB_stream_sel_t usb_stream, USB_flags_t *flags) |
| get current flags for USB FIFO | |
Variables | |
| USB_statistics_t | USB_statistics |
| USB I/O statistics. | |
USB FIFO access.
| uint8_t USB_rx_ready | ( | void | ) | [inline] |
check if at least one byte is in USB rx FIFO, i.e. the next read from USB will not block
{
return ((HL_USB_RXF_PIN & _BV(HL_USB_RXF)) == 0);
}
| int8_t USB_set_flags | ( | USB_stream_sel_t | usb_stream, | |
| USB_flag_action_t | action, | |||
| USB_flags_t | flags | |||
| ) |
set blocking/non-blocking characteristic for USB FIFO
{
FILE * stream;
unsigned int udata;
stream = get_stream_from_sel (usb_stream);
if (!stream) return -1;
udata = (unsigned int)stream->udata;
switch (action) {
case USB_flag_clear:
udata &= ~flags;
break;
case USB_flag_toggle:
udata ^= flags;
break;
case USB_flag_set:
udata |= flags;
break;
case USB_flag_assign:
udata = flags;
break;
default:
return -1;
}
stream->udata = (void*)udata;
return 0;
}
| void USBInit | ( | void | ) |
initialize USB interface
initialize USB interface
{
/* Init USB specific signals */
HL_USB_TXE_DDR &= ~( _BV(HL_USB_TXE) ); // in
HL_USB_RXF_DDR &= ~( _BV(HL_USB_RXF) ); // in
HL_USB_PWREN_DDR &= ~( _BV(HL_USB_PWREN) ); // in
HL_USB_RESET_PORT |= ( _BV(HL_USB_RESET) ); // high
HL_USB_RESET_DDR |= ( _BV(HL_USB_RESET) ); // out
/* Reset USB Controller */
// HL_USB_RESET_PORT &= ~( _BV(HL_USB_RESET) ); // low
// HL_USB_RESET_PORT |= ( _BV(HL_USB_RESET) ); // high
}
1.7.1