diff options
| author | hathach <[email protected]> | 2019-05-15 18:21:41 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-05-15 18:21:41 +0700 |
| commit | c4b153925012e7c4fe28c745e5022820798a160d (patch) | |
| tree | 01c7d3ee839746922ddade2a372310c6fa055999 /src/class/msc | |
| parent | 449a631a4a888146e8f68b6960f7fdb579fc5edf (diff) | |
| parent | 6e9324e29c3c2cc7ae36c0d7cbdb037e92ec9614 (diff) | |
Merge pull request #66 from hathach/develop
support makefile device example for all boards
Diffstat (limited to 'src/class/msc')
| -rw-r--r-- | src/class/msc/msc.h | 2 | ||||
| -rw-r--r-- | src/class/msc/msc_device.c | 19 | ||||
| -rw-r--r-- | src/class/msc/msc_device.h | 2 | ||||
| -rw-r--r-- | src/class/msc/msc_host.c | 14 | ||||
| -rw-r--r-- | src/class/msc/msc_host.h | 2 |
5 files changed, 20 insertions, 19 deletions
diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h index bdf906b45..95fac6598 100644 --- a/src/class/msc/msc.h +++ b/src/class/msc/msc.h @@ -1,7 +1,7 @@ /*
* The MIT License (MIT)
*
- * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index c486d5e04..2fd3d44a1 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -1,7 +1,7 @@ /*
* The MIT License (MIT)
*
- * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -80,7 +80,8 @@ static inline uint32_t rdwr10_get_lba(uint8_t const command[]) uint32_t lba;
memcpy(&lba, &p_rdwr10->lba, 4);
- return __be2n(lba);
+ // lba is in Big Endian format
+ return tu_ntohl(lba);
}
static inline uint16_t rdwr10_get_blockcount(uint8_t const command[])
@@ -92,7 +93,7 @@ static inline uint16_t rdwr10_get_blockcount(uint8_t const command[]) uint16_t block_count;
memcpy(&block_count, &p_rdwr10->block_count, 2);
- return __be2n_16(block_count);
+ return tu_ntohs(block_count);
}
//--------------------------------------------------------------------+
@@ -238,8 +239,8 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff {
scsi_read_capacity10_resp_t read_capa10;
- read_capa10.last_lba = ENDIAN_BE(block_count-1);
- read_capa10.block_size = ENDIAN_BE(block_size);
+ read_capa10.last_lba = tu_htonl(block_count-1);
+ read_capa10.block_size = tu_htonl(block_size);
resplen = sizeof(read_capa10);
memcpy(buffer, &read_capa10, resplen);
@@ -272,8 +273,8 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff if ( _mscd_itf.sense_key == 0 ) tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x04, 0x00);
}else
{
- read_fmt_capa.block_num = ENDIAN_BE(block_count);
- read_fmt_capa.block_size_u16 = ENDIAN_BE16(block_size);
+ read_fmt_capa.block_num = tu_htonl(block_count);
+ read_fmt_capa.block_size_u16 = tu_htons(block_size);
resplen = sizeof(read_fmt_capa);
memcpy(buffer, &read_fmt_capa, resplen);
@@ -390,7 +391,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t // For other SCSI commands
// 1. OUT : queue transfer (invoke app callback after done)
// 2. IN & Zero: Process if is built-in, else Invoke app callback. Skip DATA if zero length
- if ( (p_cbw->total_bytes > 0 ) && !TU_BIT_TEST(p_cbw->dir, 7) )
+ if ( (p_cbw->total_bytes > 0 ) && !tu_bit_test(p_cbw->dir, 7) )
{
// queue transfer
TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_out, _mscd_buf, p_msc->total_len) );
@@ -439,7 +440,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t case MSC_STAGE_DATA:
// OUT transfer, invoke callback if needed
- if ( !TU_BIT_TEST(p_cbw->dir, 7) )
+ if ( !tu_bit_test(p_cbw->dir, 7) )
{
if ( SCSI_CMD_WRITE_10 != p_cbw->command[0] )
{
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index 1baf2d19a..cf228dad9 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -1,7 +1,7 @@ /*
* The MIT License (MIT)
*
- * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index bb12c52d7..d2a1a00f7 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -1,7 +1,7 @@ /*
* The MIT License (MIT)
*
- * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -232,8 +232,8 @@ tusb_error_t tuh_msc_read10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uin scsi_read10_t cmd_read10 =
{
.cmd_code = SCSI_CMD_READ_10,
- .lba = __n2be(lba),
- .block_count = tu_u16_le2be(block_count)
+ .lba = tu_htonl(lba),
+ .block_count = tu_htons(block_count)
};
memcpy(p_msch->cbw.command, &cmd_read10, p_msch->cbw.cmd_len);
@@ -258,8 +258,8 @@ tusb_error_t tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffe scsi_write10_t cmd_write10 =
{
.cmd_code = SCSI_CMD_WRITE_10,
- .lba = __n2be(lba),
- .block_count = tu_u16_le2be(block_count)
+ .lba = tu_htonl(lba),
+ .block_count = tu_htons(block_count)
};
memcpy(p_msch->cbw.command, &cmd_write10, p_msch->cbw.cmd_len);
@@ -372,8 +372,8 @@ bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it TU_ASSERT(osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT));
}
- p_msc->last_lba = __be2n( ((scsi_read_capacity10_resp_t*)msch_buffer)->last_lba );
- p_msc->block_size = (uint16_t) __be2n( ((scsi_read_capacity10_resp_t*)msch_buffer)->block_size );
+ p_msc->last_lba = tu_ntohl( ((scsi_read_capacity10_resp_t*)msch_buffer)->last_lba );
+ p_msc->block_size = (uint16_t) tu_ntohl( ((scsi_read_capacity10_resp_t*)msch_buffer)->block_size );
p_msc->is_initialized = true;
diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index 1edce82c5..da817fbe2 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -1,7 +1,7 @@ /*
* The MIT License (MIT)
*
- * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
|
