87 lines
3.7 KiB
C
87 lines
3.7 KiB
C
/******************************************************************************
|
|
* File: MCU_USB_cfg.h
|
|
* Component: MCU_USB
|
|
* Description: Configuration header for the MCU_USB driver.
|
|
* Declares configuration structures and constants that can be
|
|
* edited to adapt the USB-CDC driver to the application's
|
|
* needs (e.g., enable/disable connection wait, timeout values,
|
|
* transmit buffer sizes).
|
|
*
|
|
* Layer: MCU (hardware abstraction) - configuration
|
|
*****************************************************************************/
|
|
|
|
#ifndef MCU_USB_CFG_H
|
|
#define MCU_USB_CFG_H
|
|
|
|
/* STD_TYPES is needed for STD_TRUE / STD_FALSE and the u8/u16/u32 typedefs
|
|
* used by the config values and timeout comparisons below. */
|
|
#include "STD_TYPES.h"
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* CONNECTION / INIT BEHAVIOR */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
/**
|
|
* @brief Whether MCU_USB_enuInit() should block until the host has opened
|
|
* the CDC serial port before returning.
|
|
*
|
|
* Set to STD_TRUE to avoid losing the first bytes sent by the application
|
|
* (the host needs ~1-2 s after power-up to enumerate and open the port).
|
|
* Set to STD_FALSE for a fire-and-forget init that returns immediately -
|
|
* useful if the firmware must not stall when no host is attached.
|
|
*/
|
|
#define MCU_USB_WAIT_FOR_CONNECTION MCU_USB_WAIT_FOR_CONNECTION_ENABLED
|
|
|
|
/**
|
|
* @brief Maximum time (in milliseconds) to wait for the host to open
|
|
* the CDC serial port during MCU_USB_enuInit().
|
|
*
|
|
* Only applies when MCU_USB_WAIT_FOR_CONNECTION is ENABLED. USB host
|
|
* enumeration typically takes ~1-2 seconds, so 3000 ms gives a
|
|
* comfortable margin. Set to 0 for an infinite wait (never times out).
|
|
* This is separate from TRANSMIT/RECEIVE timeouts because connection
|
|
* setup is a one-time event with different timing characteristics
|
|
* than per-byte I/O operations.
|
|
*/
|
|
#define MCU_USB_CONNECTION_TIMEOUT_MS 3000U
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* TIMEOUTS */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
/**
|
|
* @brief Maximum time (in milliseconds) to wait for a single transmit
|
|
* operation to complete before returning STD_NOK / STD_TIMEOUT.
|
|
*
|
|
* Applied to each transmit call in MCU_USB_prg.c. Prevents the driver
|
|
* from blocking forever if the host-side serial port is closed mid-send
|
|
* or the USB bus becomes unresponsive.
|
|
*/
|
|
#define MCU_USB_TRANSMIT_TIMEOUT_MS 1000U
|
|
|
|
/**
|
|
* @brief Maximum time (in milliseconds) to wait for a byte to arrive on
|
|
* the receive side before returning a timeout result.
|
|
*
|
|
* Applied to each blocking receive call. Prevents the driver from hanging
|
|
* when the host is attached but simply not sending anything.
|
|
*/
|
|
#define MCU_USB_RECEIVE_TIMEOUT_MS 1000U
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* BUFFER SIZING */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
/**
|
|
* @brief Size (in bytes) of the software transmit buffer used by the
|
|
* USB driver to queue outbound data.
|
|
*
|
|
* A larger buffer lets the application call MCU_USB_enuSendBuffer with
|
|
* bigger chunks without having to wait for the USB peripheral to drain,
|
|
* at the cost of more SRAM. 64 bytes matches the USB Full-Speed bulk
|
|
* endpoint packet size, which is a convenient minimum for alignment.
|
|
*/
|
|
#define MCU_USB_TRANSMIT_BUFFER_SIZE 64U
|
|
|
|
#endif /* MCU_USB_CFG_H */
|