mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
fix all device examples warnings
This commit is contained in:
parent
1a1f633922
commit
6522a8150e
@ -140,7 +140,7 @@ void midi_task(void)
|
||||
start_ms += 286;
|
||||
|
||||
// Previous positions in the note sequence.
|
||||
int previous = note_pos - 1;
|
||||
int previous = (int) (note_pos - 1);
|
||||
|
||||
// If we currently are at position 0, set the
|
||||
// previous position to the last note in the sequence.
|
||||
|
@ -277,7 +277,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
|
||||
uint8_t const* addr = (lun ? msc_disk1[lba] : msc_disk0[lba]) + offset;
|
||||
memcpy(buffer, addr, bufsize);
|
||||
|
||||
return bufsize;
|
||||
return (int32_t) bufsize;
|
||||
}
|
||||
|
||||
bool tud_msc_is_writable_cb (uint8_t lun)
|
||||
@ -305,7 +305,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
(void) lun; (void) lba; (void) offset; (void) buffer;
|
||||
#endif
|
||||
|
||||
return bufsize;
|
||||
return (int32_t) bufsize;
|
||||
}
|
||||
|
||||
// Callback invoked when received an SCSI command not in built-in list below
|
||||
@ -339,7 +339,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
|
||||
{
|
||||
if(in_xfer)
|
||||
{
|
||||
memcpy(buffer, response, resplen);
|
||||
memcpy(buffer, response, (size_t) resplen);
|
||||
}else
|
||||
{
|
||||
// SCSI output
|
||||
|
@ -159,7 +159,7 @@ static bool tud_audio_clock_get_request(uint8_t rhport, audio_control_request_t
|
||||
{
|
||||
TU_LOG1("Clock get current freq %lu\r\n", current_sample_rate);
|
||||
|
||||
audio_control_cur_4_t curf = { tu_htole32(current_sample_rate) };
|
||||
audio_control_cur_4_t curf = { (int32_t) tu_htole32(current_sample_rate) };
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, (tusb_control_request_t const *)request, &curf, sizeof(curf));
|
||||
}
|
||||
else if (request->bRequest == AUDIO_CS_REQ_RANGE)
|
||||
@ -171,8 +171,8 @@ static bool tud_audio_clock_get_request(uint8_t rhport, audio_control_request_t
|
||||
TU_LOG1("Clock get %d freq ranges\r\n", N_SAMPLE_RATES);
|
||||
for(uint8_t i = 0; i < N_SAMPLE_RATES; i++)
|
||||
{
|
||||
rangef.subrange[i].bMin = sample_rates[i];
|
||||
rangef.subrange[i].bMax = sample_rates[i];
|
||||
rangef.subrange[i].bMin = (int32_t) sample_rates[i];
|
||||
rangef.subrange[i].bMax = (int32_t) sample_rates[i];
|
||||
rangef.subrange[i].bRes = 0;
|
||||
TU_LOG1("Range %d (%d, %d, %d)\r\n", i, (int)rangef.subrange[i].bMin, (int)rangef.subrange[i].bMax, (int)rangef.subrange[i].bRes);
|
||||
}
|
||||
@ -204,7 +204,7 @@ static bool tud_audio_clock_set_request(uint8_t rhport, audio_control_request_t
|
||||
{
|
||||
TU_VERIFY(request->wLength == sizeof(audio_control_cur_4_t));
|
||||
|
||||
current_sample_rate = ((audio_control_cur_4_t const *)buf)->bCur;
|
||||
current_sample_rate = (uint32_t) ((audio_control_cur_4_t const *)buf)->bCur;
|
||||
|
||||
TU_LOG1("Clock set current freq: %ld\r\n", current_sample_rate);
|
||||
|
||||
@ -403,9 +403,9 @@ void audio_task(void)
|
||||
// Combine two channels into one
|
||||
int32_t left = *src++;
|
||||
int32_t right = *src++;
|
||||
*dst++ = (left >> 1) + (right >> 1);
|
||||
*dst++ = (int16_t) ((left >> 1) + (right >> 1));
|
||||
}
|
||||
tud_audio_write((uint8_t *)mic_buf, spk_data_size / 2);
|
||||
tud_audio_write((uint8_t *)mic_buf, (uint16_t) (spk_data_size / 2));
|
||||
spk_data_size = 0;
|
||||
}
|
||||
else if (current_resolution == 24)
|
||||
@ -418,9 +418,9 @@ void audio_task(void)
|
||||
// Combine two channels into one
|
||||
int32_t left = *src++;
|
||||
int32_t right = *src++;
|
||||
*dst++ = ((left >> 1) + (right >> 1)) & 0xffffff00;
|
||||
*dst++ = (int32_t) ((uint32_t) ((left >> 1) + (right >> 1)) & 0xffffff00ul);
|
||||
}
|
||||
tud_audio_write((uint8_t *)mic_buf, spk_data_size / 2);
|
||||
tud_audio_write((uint8_t *)mic_buf, (uint16_t) (spk_data_size / 2));
|
||||
spk_data_size = 0;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
|
||||
}
|
||||
|
||||
// first byte is length (including header), second byte is string type
|
||||
_desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2 * chr_count + 2);
|
||||
_desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
|
||||
|
||||
return _desc_str;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ tu_fifo_t* tud_audio_n_get_rx_support_ff(uint8_t func_id, uint8_t ff_idx)
|
||||
|
||||
static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t n_bytes_received)
|
||||
{
|
||||
uint8_t idxItf;
|
||||
uint8_t idxItf = 0;
|
||||
uint8_t const *dummy2;
|
||||
uint8_t idx_audio_fct = 0;
|
||||
|
||||
@ -548,7 +548,10 @@ static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t
|
||||
}
|
||||
|
||||
// Call a weak callback here - a possibility for user to get informed an audio packet was received and data gets now loaded into EP FIFO (or decoded into support RX software FIFO)
|
||||
if (tud_audio_rx_done_pre_read_cb) TU_VERIFY(tud_audio_rx_done_pre_read_cb(rhport, n_bytes_received, idx_audio_fct, audio->ep_out, audio->alt_setting[idxItf]));
|
||||
if (tud_audio_rx_done_pre_read_cb)
|
||||
{
|
||||
TU_VERIFY(tud_audio_rx_done_pre_read_cb(rhport, n_bytes_received, idx_audio_fct, audio->ep_out, audio->alt_setting[idxItf]));
|
||||
}
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_DECODING && CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
|
||||
@ -602,7 +605,10 @@ static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t
|
||||
#endif
|
||||
|
||||
// Call a weak callback here - a possibility for user to get informed decoding was completed
|
||||
if (tud_audio_rx_done_post_read_cb) TU_VERIFY(tud_audio_rx_done_post_read_cb(rhport, n_bytes_received, idx_audio_fct, audio->ep_out, audio->alt_setting[idxItf]));
|
||||
if (tud_audio_rx_done_post_read_cb)
|
||||
{
|
||||
TU_VERIFY(tud_audio_rx_done_post_read_cb(rhport, n_bytes_received, idx_audio_fct, audio->ep_out, audio->alt_setting[idxItf]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
10
src/class/vendor/vendor_device.c
vendored
10
src/class/vendor/vendor_device.c
vendored
@ -100,7 +100,7 @@ static void _prep_out_transaction (vendord_interface_t* p_itf)
|
||||
uint32_t tud_vendor_n_read (uint8_t itf, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[itf];
|
||||
uint32_t num_read = tu_fifo_read_n(&p_itf->rx_ff, buffer, bufsize);
|
||||
uint32_t num_read = tu_fifo_read_n(&p_itf->rx_ff, buffer, (uint16_t) bufsize);
|
||||
_prep_out_transaction(p_itf);
|
||||
return num_read;
|
||||
}
|
||||
@ -133,7 +133,7 @@ static uint16_t maybe_transmit(vendord_interface_t* p_itf)
|
||||
uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[itf];
|
||||
uint16_t ret = tu_fifo_write_n(&p_itf->tx_ff, buffer, bufsize);
|
||||
uint16_t ret = tu_fifo_write_n(&p_itf->tx_ff, buffer, (uint16_t) bufsize);
|
||||
if (tu_fifo_count(&p_itf->tx_ff) >= CFG_TUD_VENDOR_EPSIZE) {
|
||||
maybe_transmit(p_itf);
|
||||
}
|
||||
@ -231,7 +231,7 @@ uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, ui
|
||||
if ( p_vendor->ep_in ) maybe_transmit(p_vendor);
|
||||
}
|
||||
|
||||
return (uintptr_t) p_desc - (uintptr_t) desc_itf;
|
||||
return (uint16_t) ((uintptr_t) p_desc - (uintptr_t) desc_itf);
|
||||
}
|
||||
|
||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
@ -252,7 +252,7 @@ bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
||||
if ( ep_addr == p_itf->ep_out )
|
||||
{
|
||||
// Receive new data
|
||||
tu_fifo_write_n(&p_itf->rx_ff, p_itf->epout_buf, xferred_bytes);
|
||||
tu_fifo_write_n(&p_itf->rx_ff, p_itf->epout_buf, (uint16_t) xferred_bytes);
|
||||
|
||||
// Invoked callback if any
|
||||
if (tud_vendor_rx_cb) tud_vendor_rx_cb(itf);
|
||||
@ -261,7 +261,7 @@ bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
||||
}
|
||||
else if ( ep_addr == p_itf->ep_in )
|
||||
{
|
||||
if (tud_vendor_tx_cb) tud_vendor_tx_cb(itf, xferred_bytes);
|
||||
if (tud_vendor_tx_cb) tud_vendor_tx_cb(itf, (uint16_t) xferred_bytes);
|
||||
// Send complete, try to send more if possible
|
||||
maybe_transmit(p_itf);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm
|
||||
{
|
||||
tusb_desc_vs_itf_t const *vs = _get_desc_vs(stm);
|
||||
uint_fast8_t fmtnum = param->bFormatIndex;
|
||||
TU_ASSERT(fmtnum <= vs->stm.bNumFormats);
|
||||
TU_ASSERT(vs && fmtnum <= vs->stm.bNumFormats);
|
||||
if (!fmtnum) {
|
||||
if (1 < vs->stm.bNumFormats) return true; /* Need to negotiate all variables. */
|
||||
fmtnum = 1;
|
||||
@ -393,6 +393,7 @@ static bool _negotiate_streaming_parameters(videod_streaming_interface_t const *
|
||||
uint_fast8_t frmnum = param->bFrameIndex;
|
||||
if (!frmnum) {
|
||||
tusb_desc_vs_itf_t const *vs = _get_desc_vs(stm);
|
||||
TU_ASSERT(vs);
|
||||
void const *end = _end_of_streaming_descriptor(vs);
|
||||
tusb_desc_cs_video_fmt_uncompressed_t const *fmt = _find_desc_format(tu_desc_next(vs), end, fmtnum);
|
||||
switch (request) {
|
||||
@ -407,15 +408,16 @@ static bool _negotiate_streaming_parameters(videod_streaming_interface_t const *
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
param->bFrameIndex = frmnum;
|
||||
param->bFrameIndex = (uint8_t) frmnum;
|
||||
/* Set the parameters determined by the frame */
|
||||
tusb_desc_cs_video_frm_uncompressed_t const *frm = _find_desc_frame(tu_desc_next(fmt), end, frmnum);
|
||||
param->dwMaxVideoFrameSize = frm->wWidth * frm->wHeight * fmt->bBitsPerPixel / 8;
|
||||
param->dwMaxVideoFrameSize = (uint32_t) (frm->wWidth * frm->wHeight * fmt->bBitsPerPixel / 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!param->dwFrameInterval) {
|
||||
tusb_desc_vs_itf_t const *vs = _get_desc_vs(stm);
|
||||
TU_ASSERT(vs);
|
||||
void const *end = _end_of_streaming_descriptor(vs);
|
||||
tusb_desc_cs_video_fmt_uncompressed_t const *fmt = _find_desc_format(tu_desc_next(vs), end, fmtnum);
|
||||
tusb_desc_cs_video_frm_uncompressed_t const *frm = _find_desc_frame(tu_desc_next(fmt), end, frmnum);
|
||||
@ -532,7 +534,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t
|
||||
/* Open the notification endpoint */
|
||||
TU_ASSERT(usbd_edpt_open(rhport, notif));
|
||||
}
|
||||
self->cur = (void const*)vc - beg;
|
||||
self->cur = (uint16_t) ((void const*)vc - beg);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -550,7 +552,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
|
||||
for (i = 0; i < TU_ARRAY_SIZE(stm->desc.ep); ++i) {
|
||||
uint_fast16_t ofs_ep = stm->desc.ep[i];
|
||||
if (!ofs_ep) break;
|
||||
uint_fast8_t ep_adr = _desc_ep_addr(desc + ofs_ep);
|
||||
uint8_t ep_adr = _desc_ep_addr(desc + ofs_ep);
|
||||
usbd_edpt_close(rhport, ep_adr);
|
||||
stm->desc.ep[i] = 0;
|
||||
TU_LOG2(" close EP%02x\n", ep_adr);
|
||||
@ -567,7 +569,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
|
||||
TU_VERIFY(cur < end);
|
||||
uint_fast8_t numeps = ((tusb_desc_interface_t const *)cur)->bNumEndpoints;
|
||||
TU_ASSERT(numeps <= TU_ARRAY_SIZE(stm->desc.ep));
|
||||
stm->desc.cur = cur - desc; /* Save the offset of the new settings */
|
||||
stm->desc.cur = (uint16_t) (cur - desc); /* Save the offset of the new settings */
|
||||
if (!altnum) {
|
||||
/* initialize streaming settings */
|
||||
stm->max_payload_transfer_size = 0;
|
||||
@ -594,7 +596,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
|
||||
stm->max_payload_transfer_size = max_size;
|
||||
}
|
||||
TU_ASSERT(usbd_edpt_open(rhport, ep));
|
||||
stm->desc.ep[i] = cur - desc;
|
||||
stm->desc.ep[i] = (uint16_t) (cur - desc);
|
||||
TU_LOG2(" open EP%02x\n", _desc_ep_addr(cur));
|
||||
}
|
||||
/* initialize payload header */
|
||||
@ -976,7 +978,7 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu
|
||||
|
||||
/* Find EP address */
|
||||
void const *desc = _videod_itf[stm->index_vc].beg;
|
||||
uint_fast8_t ep_addr = 0;
|
||||
uint8_t ep_addr = 0;
|
||||
for (uint_fast8_t i = 0; i < CFG_TUD_VIDEO_STREAMING; ++i) {
|
||||
uint_fast16_t ofs_ep = stm->desc.ep[i];
|
||||
if (!ofs_ep) continue;
|
||||
@ -985,7 +987,7 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu
|
||||
}
|
||||
if (!ep_addr) return false;
|
||||
|
||||
TU_VERIFY( usbd_edpt_claim(0, ep_addr));
|
||||
TU_VERIFY( usbd_edpt_claim(0, ep_addr) );
|
||||
/* update the packet header */
|
||||
tusb_video_payload_header_t *hdr = (tusb_video_payload_header_t*)stm->ep_buf;
|
||||
hdr->FrameID ^= 1;
|
||||
@ -994,7 +996,7 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu
|
||||
stm->buffer = (uint8_t*)buffer;
|
||||
stm->bufsize = bufsize;
|
||||
uint_fast16_t pkt_len = _prepare_in_payload(stm);
|
||||
TU_ASSERT( usbd_edpt_xfer(0, ep_addr, stm->ep_buf, pkt_len), 0);
|
||||
TU_ASSERT( usbd_edpt_xfer(0, ep_addr, stm->ep_buf, (uint16_t) pkt_len), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1034,7 +1036,7 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
|
||||
|
||||
/* Find available interface */
|
||||
videod_interface_t *self = NULL;
|
||||
uint_fast8_t ctl_idx;
|
||||
uint8_t ctl_idx;
|
||||
for (ctl_idx = 0; ctl_idx < CFG_TUD_VIDEO; ++ctl_idx) {
|
||||
if (_videod_itf[ctl_idx].beg) continue;
|
||||
self = &_videod_itf[ctl_idx];
|
||||
@ -1051,10 +1053,10 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
|
||||
uint_fast8_t bInCollection = vc->ctl.bInCollection;
|
||||
/* Find the end of the video interface descriptor */
|
||||
void const *cur = _next_desc_itf(itf_desc, end);
|
||||
for (uint_fast8_t stm_idx = 0; stm_idx < bInCollection; ++stm_idx) {
|
||||
for (uint8_t stm_idx = 0; stm_idx < bInCollection; ++stm_idx) {
|
||||
videod_streaming_interface_t *stm = NULL;
|
||||
/* find free streaming interface handle */
|
||||
for (uint_fast8_t i = 0; i < CFG_TUD_VIDEO_STREAMING; ++i) {
|
||||
for (uint8_t i = 0; i < CFG_TUD_VIDEO_STREAMING; ++i) {
|
||||
if (_videod_streaming_itf[i].desc.beg) continue;
|
||||
stm = &_videod_streaming_itf[i];
|
||||
self->stm[stm_idx] = i;
|
||||
@ -1063,12 +1065,12 @@ uint16_t videod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
|
||||
TU_ASSERT(stm, 0);
|
||||
stm->index_vc = ctl_idx;
|
||||
stm->index_vs = stm_idx;
|
||||
stm->desc.beg = (uintptr_t)cur - (uintptr_t)itf_desc;
|
||||
stm->desc.beg = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
|
||||
cur = _next_desc_itf(cur, end);
|
||||
stm->desc.end = (uintptr_t)cur - (uintptr_t)itf_desc;
|
||||
stm->desc.end = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
|
||||
}
|
||||
self->len = (uintptr_t)cur - (uintptr_t)itf_desc;
|
||||
return (uintptr_t)cur - (uintptr_t)itf_desc;
|
||||
self->len = (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
|
||||
return (uint16_t) ((uintptr_t)cur - (uintptr_t)itf_desc);
|
||||
}
|
||||
|
||||
// Invoked when a control transfer occurred on an interface of this class
|
||||
@ -1134,7 +1136,7 @@ bool videod_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint3
|
||||
/* Claim the endpoint */
|
||||
TU_VERIFY( usbd_edpt_claim(rhport, ep_addr), 0);
|
||||
uint_fast16_t pkt_len = _prepare_in_payload(stm);
|
||||
TU_ASSERT( usbd_edpt_xfer(rhport, ep_addr, stm->ep_buf, pkt_len), 0);
|
||||
TU_ASSERT( usbd_edpt_xfer(rhport, ep_addr, stm->ep_buf, (uint16_t) pkt_len), 0);
|
||||
} else {
|
||||
stm->buffer = NULL;
|
||||
stm->bufsize = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user