rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
usbconsole.cpp File Reference

Functions

static void onUsbDataReceived (uint8_t *pu8Data, uint32_t u32ReceviedSize)
 
static msg_t _putt (void *ip, uint8_t b, sysinterval_t timeout)
 
static size_t _writet (void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout)
 
static msg_t _put (void *ip, uint8_t b)
 
static size_t _write (void *ip, const uint8_t *bp, size_t n)
 
static size_t _readt (void *ip, uint8_t *bp, size_t n, sysinterval_t timeout)
 
static msg_t _gett (void *ip, sysinterval_t timeout)
 
static msg_t _get (void *ip)
 
static size_t _read (void *ip, uint8_t *bp, size_t n)
 
static msg_t _ctl (void *ip, unsigned int operation, void *arg)
 
static void usb_VBus_handler (uint8_t channel)
 
void usb_serial_start (void)
 Main function of PDL.
 
bool is_usb_serial_ready ()
 

Variables

static usb_buf_s usbBuf
 
static bool isUsbSerialInitialized = false
 
static bool isUsbSerialInitStarted = false
 
static const struct BaseChannelVMT usbChannelVmt
 
BaseChannel SDU1 = { .vmt = &usbChannelVmt }
 

Function Documentation

◆ _ctl()

static msg_t _ctl ( void *  ip,
unsigned int  operation,
void *  arg 
)
static

Definition at line 103 of file usbconsole.cpp.

103 {
104 return MSG_OK;
105}

◆ _get()

static msg_t _get ( void *  ip)
static

Definition at line 96 of file usbconsole.cpp.

96 {
97 return _gett(ip, USB_WRITE_TIMEOUT);
98}
static msg_t _gett(void *ip, sysinterval_t timeout)
Here is the call graph for this function:

◆ _gett()

static msg_t _gett ( void *  ip,
sysinterval_t  timeout 
)
static

Definition at line 87 of file usbconsole.cpp.

87 {
88 (void)ip;
89 (void)timeout;
90 //msg_t msg = UsbDeviceCdcCom_ReceiveByte();
91 uint8_t b;
92 if (_readt(ip, &b, 1, timeout) == 1)
93 return (msg_t)b;
94 return MSG_TIMEOUT;
95}
static size_t _readt(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout)

Referenced by _get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _put()

static msg_t _put ( void *  ip,
uint8_t  b 
)
static

Definition at line 63 of file usbconsole.cpp.

63 {
64 (void)ip;
65 UsbDeviceCdcCom_SendByte(b);
66 return MSG_OK;
67}

◆ _putt()

static msg_t _putt ( void *  ip,
uint8_t  b,
sysinterval_t  timeout 
)
static

Definition at line 51 of file usbconsole.cpp.

51 {
52 (void)ip;
53 (void)timeout;
54 UsbDeviceCdcCom_SendByte(b);
55 return MSG_OK;
56}

◆ _read()

static size_t _read ( void *  ip,
uint8_t *  bp,
size_t  n 
)
static

Definition at line 99 of file usbconsole.cpp.

99 {
100 (void)ip;
101 return _readt(ip, bp, n, USB_WRITE_TIMEOUT);
102}
Here is the call graph for this function:

◆ _readt()

static size_t _readt ( void *  ip,
uint8_t *  bp,
size_t  n,
sysinterval_t  timeout 
)
static

Definition at line 71 of file usbconsole.cpp.

71 {
72 //size_t numBytesRead = UsbDeviceCdcCom_ReceiveBuffer(bp, n);
73
74 return (size_t)iqReadTimeout(&usbBuf.fifoRxQueue, bp, n, timeout);
75/*
76 // if we don't have all bytes immediately
77 if (numBytesRead < n) {
78 osalSysLock();
79 threadrx = chThdGetSelfX();
80 osalThreadSuspendTimeoutS(&threadrx, timeout);
81 osalSysUnlock();
82 numBytesRead += UsbDeviceCdcCom_ReceiveBuffer(bp + numBytesRead, n - numBytesRead);
83 }
84 return numBytesRead;
85*/
86}
static usb_buf_s usbBuf

Referenced by _gett(), and _read().

Here is the caller graph for this function:

◆ _write()

static size_t _write ( void *  ip,
const uint8_t *  bp,
size_t  n 
)
static

Definition at line 68 of file usbconsole.cpp.

68 {
69 return _writet(ip, bp, n, USB_WRITE_TIMEOUT);
70}
static size_t _writet(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout)
Here is the call graph for this function:

◆ _writet()

static size_t _writet ( void *  ip,
const uint8_t *  bp,
size_t  n,
sysinterval_t  timeout 
)
static

Definition at line 57 of file usbconsole.cpp.

57 {
58 (void)ip;
59 (void)timeout;
60 UsbDeviceCdcCom_SendBuffer((uint8_t *)bp, n);
61 return n;
62}

Referenced by _write().

Here is the caller graph for this function:

◆ is_usb_serial_ready()

bool is_usb_serial_ready ( )

Definition at line 152 of file usbconsole.cpp.

152 {
153 return isUsbSerialInitialized /*&& SDU1.config->usbp->state == USB_ACTIVE*/;
154}
static bool isUsbSerialInitialized

Referenced by Rs232ReceiveByte(), and updateTunerStudioState().

Here is the caller graph for this function:

◆ onUsbDataReceived()

static void onUsbDataReceived ( uint8_t *  pu8Data,
uint32_t  u32ReceviedSize 
)
static

Definition at line 30 of file usbconsole.cpp.

30 {
31 osalSysLockFromISR();
32
33 // copy the data to the FIFO buffer
34 for (int i = 0; i < u32ReceviedSize; i++) {
35 if (iqPutI(&usbBuf.fifoRxQueue, *pu8Data++) != Q_OK) {
36 break; // todo: ignore overflow?
37 }
38 }
39
40 // tell the reader thread to wake up
41#if 0
42 if (threadrx != NULL) {
43 osalThreadResumeI(&threadrx, MSG_OK);
44 }
45#endif
46
47 osalSysUnlockFromISR();
48}

Referenced by usb_serial_start().

Here is the caller graph for this function:

◆ usb_serial_start()

void usb_serial_start ( void  )

Main function of PDL.

Returns
uint32_t return value, if needed

Definition at line 128 of file usbconsole.cpp.

128 {
130 return;
131
133
135
136 // init FIFO queue
137 iqObjectInit(&usbBuf.fifoRxQueue, usbBuf.buffer, sizeof(usbBuf.buffer), NULL, NULL);
138
139 UsbDeviceCdcCom_SetReceivedCallback(onUsbDataReceived);
140
142
143 // init VBus detector for P60 (INT31_0)
144 SetPinFunc_INT31_0(0u);
145 _pal_lld_setpadeventhandler(31, ExIntRisingEdge, usb_VBus_handler);
146
147
149
150}
static void onUsbDataReceived(uint8_t *pu8Data, uint32_t u32ReceviedSize)
static void usb_VBus_handler(uint8_t channel)
static bool isUsbSerialInitStarted
void UsbConfig_UsbInit(void)
Initialize USB.
void UsbConfig_SwitchMode(void)
Switch USB mode (dummy if USB is disabled)

Referenced by Rs232Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_VBus_handler()

static void usb_VBus_handler ( uint8_t  channel)
static

Definition at line 116 of file usbconsole.cpp.

116 {
117 // call it only if the USB driver is already initialized
120}

Referenced by usb_serial_start().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ isUsbSerialInitialized

bool isUsbSerialInitialized = false
static

◆ isUsbSerialInitStarted

bool isUsbSerialInitStarted = false
static

Definition at line 27 of file usbconsole.cpp.

Referenced by usb_serial_start().

◆ SDU1

BaseChannel SDU1 = { .vmt = &usbChannelVmt }

Definition at line 113 of file usbconsole.cpp.

113{ .vmt = &usbChannelVmt };
static const struct BaseChannelVMT usbChannelVmt

Referenced by is_usb_serial_ready(), openBltUnexpectedByte(), readch(), Rs232ReceiveByte(), Rs232TransmitByte(), Rs232TransmitPacket(), serialPrint(), and usb_serial_start().

◆ usbBuf

usb_buf_s usbBuf
static

Definition at line 23 of file usbconsole.cpp.

Referenced by _readt(), onUsbDataReceived(), and usb_serial_start().

◆ usbChannelVmt

const struct BaseChannelVMT usbChannelVmt
static
Initial value:
= {
.instance_offset = (size_t)0, .write = _write, .read = _read, .put = _put, .get = _get,
.putt = _putt, .gett = _gett, .writet = _writet, .readt = _readt, .ctl = _ctl
}
static bool write(void *, uint32_t, const uint8_t *, uint32_t)
static bool read(void *instance, uint32_t startblk, uint8_t *buffer, uint32_t)
static msg_t _get(void *ip)
static msg_t _ctl(void *ip, unsigned int operation, void *arg)
static msg_t _put(void *ip, uint8_t b)
static size_t _write(void *ip, const uint8_t *bp, size_t n)
static msg_t _putt(void *ip, uint8_t b, sysinterval_t timeout)
static size_t _read(void *ip, uint8_t *bp, size_t n)

Definition at line 108 of file usbconsole.cpp.

108 {
109 .instance_offset = (size_t)0, .write = _write, .read = _read, .put = _put, .get = _get,
110 .putt = _putt, .gett = _gett, .writet = _writet, .readt = _readt, .ctl = _ctl
111};

Go to the source code of this file.