CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
ccid_driver.cpp File Reference
#include "mod_gpg/openpgp/ccid.h"
#include "mod_gpg/openpgp/openpgp.h"
#include "cdc_log.h"
#include "tusb.h"
#include "device/usbd_pvt.h"
#include <esp_attr.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define CCID_LOG(tag, fmt, ...)
#define CCID_LOG_E(tag, fmt, ...)
#define CCID_LOG_W(tag, fmt, ...)
#define CCID_RX_BUF_SIZE   (CCID_MAX_MSG_SIZE + CCID_HEADER_SIZE)
#define CCID_TX_BUF_SIZE   (CCID_MAX_MSG_SIZE + CCID_HEADER_SIZE)

Functions

static void ccid_driver_init (void)
static void ccid_driver_reset (uint8_t rhport)
static uint16_t ccid_driver_open (uint8_t rhport, tusb_desc_interface_t const *desc_itf, uint16_t max_len)
static bool ccid_driver_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
static bool ccid_driver_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
void ccid_driver_link_anchor (void)
 Initializes CCID transport and backing OpenPGP applet.
usbd_class_driver_t const * usbd_app_driver_get_cb (uint8_t *driver_count)

Variables

static const char * TAG = "CCID"
static uint8_t ccid_rx_buf [(2048+10)]
static uint8_t ccid_tx_buf [(2048+10)]
struct { 
   bool   initialized 
   uint8_t   itf_num 
   uint8_t   ep_in 
   uint8_t   ep_out 
   uint8_t   rhport 
   uint16_t   rx_len 
   bool   rx_pending 
   uint32_t   rx_count 
   uint32_t   tx_count 
   uint32_t   error_count 
ccid_state
static usbd_class_driver_t const ccid_driver

Macro Definition Documentation

◆ CCID_LOG

#define CCID_LOG ( tag,
fmt,
... )
Value:
LOG_I(tag, fmt, ##__VA_ARGS__)
#define LOG_I(tag, fmt,...)
Definition cdc_log.h:147

Definition at line 16 of file ccid_driver.cpp.

Referenced by ccid_driver_init().

◆ CCID_LOG_E

#define CCID_LOG_E ( tag,
fmt,
... )
Value:
LOG_E(tag, fmt, ##__VA_ARGS__)
#define LOG_E(tag, fmt,...)
Definition cdc_log.h:145

Definition at line 17 of file ccid_driver.cpp.

◆ CCID_LOG_W

#define CCID_LOG_W ( tag,
fmt,
... )
Value:
LOG_W(tag, fmt, ##__VA_ARGS__)
#define LOG_W(tag, fmt,...)
Definition cdc_log.h:146

Definition at line 18 of file ccid_driver.cpp.

◆ CCID_RX_BUF_SIZE

#define CCID_RX_BUF_SIZE   (CCID_MAX_MSG_SIZE + CCID_HEADER_SIZE)

Definition at line 20 of file ccid_driver.cpp.

◆ CCID_TX_BUF_SIZE

#define CCID_TX_BUF_SIZE   (CCID_MAX_MSG_SIZE + CCID_HEADER_SIZE)

Definition at line 21 of file ccid_driver.cpp.

Function Documentation

◆ ccid_driver_control_xfer_cb()

bool ccid_driver_control_xfer_cb ( uint8_t rhport,
uint8_t stage,
tusb_control_request_t const * request )
static

Definition at line 110 of file ccid_driver.cpp.

References ccid_state, and rhport.

◆ ccid_driver_init()

void ccid_driver_init ( void )
static

Definition at line 42 of file ccid_driver.cpp.

References CCID_LOG, ccid_state, and TAG.

◆ ccid_driver_link_anchor()

void ccid_driver_link_anchor ( void )

Initializes CCID transport and backing OpenPGP applet.

Returns
true if initialization succeeded.

Definition at line 226 of file ccid_driver.cpp.

Referenced by ccid_init().

◆ ccid_driver_open()

uint16_t ccid_driver_open ( uint8_t rhport,
tusb_desc_interface_t const * desc_itf,
uint16_t max_len )
static

Definition at line 57 of file ccid_driver.cpp.

References ccid_rx_buf, ccid_state, and rhport.

◆ ccid_driver_reset()

void ccid_driver_reset ( uint8_t rhport)
static

Definition at line 47 of file ccid_driver.cpp.

References ccid_state, and rhport.

◆ ccid_driver_xfer_cb()

bool ccid_driver_xfer_cb ( uint8_t rhport,
uint8_t ep_addr,
xfer_result_t result,
uint32_t xferred_bytes )
static

◆ usbd_app_driver_get_cb()

usbd_class_driver_t const * usbd_app_driver_get_cb ( uint8_t * driver_count)

Definition at line 228 of file ccid_driver.cpp.

References ccid_driver.

Variable Documentation

◆ ccid_driver

usbd_class_driver_t const ccid_driver
static
Initial value:
= {
.name = "CCID",
.deinit = NULL,
.control_xfer_cb = ccid_driver_control_xfer_cb,
.xfer_cb = ccid_driver_xfer_cb,
.xfer_isr = NULL,
.sof = NULL
}
static void ccid_driver_init(void)
static uint16_t ccid_driver_open(uint8_t rhport, tusb_desc_interface_t const *desc_itf, uint16_t max_len)
static void ccid_driver_reset(uint8_t rhport)
static bool ccid_driver_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
static bool ccid_driver_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)

Definition at line 209 of file ccid_driver.cpp.

Referenced by usbd_app_driver_get_cb().

◆ ccid_rx_buf

uint8_t ccid_rx_buf[(2048+10)]
static

Definition at line 24 of file ccid_driver.cpp.

Referenced by ccid_driver_open(), and ccid_driver_xfer_cb().

◆ [struct]

◆ ccid_tx_buf

uint8_t ccid_tx_buf[(2048+10)]
static

Definition at line 25 of file ccid_driver.cpp.

Referenced by ccid_driver_xfer_cb().

◆ ep_in

uint8_t ep_in

Definition at line 30 of file ccid_driver.cpp.

◆ ep_out

uint8_t ep_out

Definition at line 31 of file ccid_driver.cpp.

◆ error_count

uint32_t error_count

Definition at line 39 of file ccid_driver.cpp.

◆ initialized

bool initialized

Definition at line 28 of file ccid_driver.cpp.

◆ itf_num

uint8_t itf_num

Definition at line 29 of file ccid_driver.cpp.

◆ rhport

uint8_t rhport

◆ rx_count

uint32_t rx_count

Definition at line 37 of file ccid_driver.cpp.

◆ rx_len

uint16_t rx_len

Definition at line 34 of file ccid_driver.cpp.

◆ rx_pending

bool rx_pending

Definition at line 35 of file ccid_driver.cpp.

◆ TAG

const char* TAG = "CCID"
static

Definition at line 14 of file ccid_driver.cpp.

◆ tx_count

uint32_t tx_count

Definition at line 38 of file ccid_driver.cpp.