move protocol message to stack, disable battery in PWR's CR3
there is still issue with CC1/CC2 pull down resistor and vstate is not correct.
This commit is contained in:
@@ -38,10 +38,28 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
enum {
|
||||
TCD_EVENT_INVALID = 0,
|
||||
TCD_EVENT_CC_CHANGED,
|
||||
TCD_EVENT_RX_COMPLETE,
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t rhport;
|
||||
uint8_t event_id;
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint8_t cc_state[2];
|
||||
} cc_changed;
|
||||
|
||||
struct {
|
||||
uint16_t xferred_bytes;
|
||||
uint8_t result;
|
||||
} rx_complete;
|
||||
};
|
||||
|
||||
} tcd_event_t;;
|
||||
|
||||
@@ -68,4 +86,38 @@ void tcd_int_handler(uint8_t rhport);
|
||||
bool tcd_rx_start(uint8_t rhport, uint8_t* buffer, uint16_t total_bytes);
|
||||
bool tcd_tx_start(uint8_t rhport, uint8_t const* buffer, uint16_t total_bytes);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Event API (implemented by stack)
|
||||
// Called by TCD to notify stack
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
extern void tcd_event_handler(tcd_event_t const * event, bool in_isr);
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline
|
||||
void tcd_event_cc_changed(uint8_t rhport, uint8_t cc1, uint8_t cc2, bool in_isr) {
|
||||
tcd_event_t event = {
|
||||
.rhport = rhport,
|
||||
.event_id = TCD_EVENT_CC_CHANGED,
|
||||
.cc_changed = {
|
||||
.cc_state = {cc1, cc2 }
|
||||
}
|
||||
};
|
||||
|
||||
tcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline
|
||||
void tcd_event_rx_complete(uint8_t rhport, uint16_t xferred_bytes, uint8_t result, bool in_isr) {
|
||||
tcd_event_t event = {
|
||||
.rhport = rhport,
|
||||
.event_id = TCD_EVENT_RX_COMPLETE,
|
||||
.rx_complete = {
|
||||
.xferred_bytes = xferred_bytes,
|
||||
.result = result
|
||||
}
|
||||
};
|
||||
|
||||
tcd_event_handler(&event, in_isr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user