mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 01:43:47 +00:00
rename dfu API
- tud_dfu_dnload_complete() -> tud_dfu_download_complete() - tud_dfu_req_dnload_data_cb() -> tud_dfu_download_cb() - tud_dfu_req_upload_data_cb() -> tud_dfu_upload_cb()
This commit is contained in:
parent
86d511f244
commit
ac8d0abecf
@ -135,7 +135,7 @@ uint32_t tud_dfu_get_status_cb(uint8_t alt, uint8_t state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tud_dfu_req_dnload_data_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length)
|
void tud_dfu_download_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length)
|
||||||
{
|
{
|
||||||
(void) data;
|
(void) data;
|
||||||
printf(" Received Alt %u BlockNum %u of length %u\r\n", alt, wBlockNum, length);
|
printf(" Received Alt %u BlockNum %u of length %u\r\n", alt, wBlockNum, length);
|
||||||
@ -147,7 +147,7 @@ void tud_dfu_req_dnload_data_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tud_dfu_dnload_complete();
|
tud_dfu_download_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_dfu_device_data_done_check_cb(uint8_t alt)
|
bool tud_dfu_device_data_done_check_cb(uint8_t alt)
|
||||||
@ -167,7 +167,7 @@ void tud_dfu_abort_cb(uint8_t alt)
|
|||||||
const uint8_t upload_test[2][UPLOAD_SIZE] = {"Hello world from TinyUSB DFU! - Partition 0",
|
const uint8_t upload_test[2][UPLOAD_SIZE] = {"Hello world from TinyUSB DFU! - Partition 0",
|
||||||
"Hello world from TinyUSB DFU! - Partition 1"};
|
"Hello world from TinyUSB DFU! - Partition 1"};
|
||||||
|
|
||||||
uint16_t tud_dfu_req_upload_data_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length)
|
uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length)
|
||||||
{
|
{
|
||||||
(void) block_num;
|
(void) block_num;
|
||||||
(void) length;
|
(void) length;
|
||||||
|
@ -134,10 +134,13 @@ void midi_task(void)
|
|||||||
uint8_t packet[4];
|
uint8_t packet[4];
|
||||||
while ( tud_midi_available() ) tud_midi_packet_read(packet);
|
while ( tud_midi_available() ) tud_midi_packet_read(packet);
|
||||||
|
|
||||||
// send note every 1000 ms
|
// send note periodically
|
||||||
if (board_millis() - start_ms < 286) return; // not enough time
|
if (board_millis() - start_ms < 1000) return; // not enough time
|
||||||
start_ms += 286;
|
start_ms += 1000;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
#else
|
||||||
// Previous positions in the note sequence.
|
// Previous positions in the note sequence.
|
||||||
int previous = note_pos - 1;
|
int previous = note_pos - 1;
|
||||||
|
|
||||||
@ -158,6 +161,7 @@ void midi_task(void)
|
|||||||
|
|
||||||
// If we are at the end of the sequence, start over.
|
// If we are at the end of the sequence, start over.
|
||||||
if (note_pos >= sizeof(note_sequence)) note_pos = 0;
|
if (note_pos >= sizeof(note_sequence)) note_pos = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -283,9 +283,9 @@ static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * re
|
|||||||
{
|
{
|
||||||
TU_VERIFY( wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, 0);
|
TU_VERIFY( wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, 0);
|
||||||
uint16_t retval = 0;
|
uint16_t retval = 0;
|
||||||
if (tud_dfu_req_upload_data_cb)
|
if (tud_dfu_upload_cb)
|
||||||
{
|
{
|
||||||
tud_dfu_req_upload_data_cb(_dfu_state_ctx.alt, block_num, (uint8_t *)_dfu_state_ctx.transfer_buf, wLength);
|
tud_dfu_upload_cb(_dfu_state_ctx.alt, block_num, (uint8_t *)_dfu_state_ctx.transfer_buf, wLength);
|
||||||
}
|
}
|
||||||
tud_control_xfer(rhport, request, _dfu_state_ctx.transfer_buf, retval);
|
tud_control_xfer(rhport, request, _dfu_state_ctx.transfer_buf, retval);
|
||||||
return retval;
|
return retval;
|
||||||
@ -330,11 +330,11 @@ static void dfu_req_dnload_reply(uint8_t rhport, tusb_control_request_t const *
|
|||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
TU_VERIFY( request->wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, );
|
TU_VERIFY( request->wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, );
|
||||||
tud_dfu_req_dnload_data_cb(_dfu_state_ctx.alt,_dfu_state_ctx.block, (uint8_t *)_dfu_state_ctx.transfer_buf, _dfu_state_ctx.length);
|
tud_dfu_download_cb(_dfu_state_ctx.alt,_dfu_state_ctx.block, (uint8_t *)_dfu_state_ctx.transfer_buf, _dfu_state_ctx.length);
|
||||||
_dfu_state_ctx.blk_transfer_in_proc = false;
|
_dfu_state_ctx.blk_transfer_in_proc = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tud_dfu_dnload_complete(void)
|
void tud_dfu_download_complete(void)
|
||||||
{
|
{
|
||||||
if (_dfu_state_ctx.state == DFU_DNBUSY)
|
if (_dfu_state_ctx.state == DFU_DNBUSY)
|
||||||
{
|
{
|
||||||
|
@ -58,11 +58,11 @@ TU_ATTR_WEAK uint32_t tud_dfu_get_status_cb(uint8_t alt, uint8_t state);
|
|||||||
// This callback takes the wBlockNum chunk of length length and provides it
|
// This callback takes the wBlockNum chunk of length length and provides it
|
||||||
// to the application at the data pointer. This data is only valid for this
|
// to the application at the data pointer. This data is only valid for this
|
||||||
// call, so the app must use it not or copy it.
|
// call, so the app must use it not or copy it.
|
||||||
void tud_dfu_req_dnload_data_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length);
|
void tud_dfu_download_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length);
|
||||||
|
|
||||||
// Must be called when the application is done using the last block of data
|
// Must be called when the application is done using the last block of data
|
||||||
// provided by tud_dfu_req_dnload_data_cb
|
// provided by tud_dfu_download_cb
|
||||||
void tud_dfu_dnload_complete(void);
|
void tud_dfu_download_complete(void);
|
||||||
|
|
||||||
// Invoked during the last DFU_DNLOAD request, signifying that the host believes
|
// Invoked during the last DFU_DNLOAD request, signifying that the host believes
|
||||||
// it is done transmitting data.
|
// it is done transmitting data.
|
||||||
@ -79,7 +79,7 @@ TU_ATTR_WEAK void tud_dfu_abort_cb(uint8_t alt);
|
|||||||
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
||||||
// This callback must populate data with up to length bytes
|
// This callback must populate data with up to length bytes
|
||||||
// Return the number of bytes to write
|
// Return the number of bytes to write
|
||||||
TU_ATTR_WEAK uint16_t tud_dfu_req_upload_data_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length);
|
TU_ATTR_WEAK uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length);
|
||||||
|
|
||||||
// Invoked when a DFU_DETACH request is received
|
// Invoked when a DFU_DETACH request is received
|
||||||
TU_ATTR_WEAK void tud_dfu_reboot_cb(void);
|
TU_ATTR_WEAK void tud_dfu_reboot_cb(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user