<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>MCU on Anthony</title><link>https://gogo.anthony42.eu.org/categories/mcu/</link><description>Recent content in MCU on Anthony</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 24 Apr 2026 11:21:22 +0800</lastBuildDate><atom:link href="https://gogo.anthony42.eu.org/categories/mcu/index.xml" rel="self" type="application/rss+xml"/><item><title>MM32 CDC MSC</title><link>https://gogo.anthony42.eu.org/posts/mm32-cdc-msc/</link><pubDate>Fri, 24 Apr 2026 11:21:22 +0800</pubDate><guid>https://gogo.anthony42.eu.org/posts/mm32-cdc-msc/</guid><description>&lt;pre tabindex="0"&gt;&lt;code&gt;#define CFG_TUD_MSC 1
#define EPNUM_MSC_OUT 0x03
#define EPNUM_MSC_IN 0x83
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
uint8_t const desc_fs_configuration[] =
{
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64),
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
};
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;add &lt;code&gt;msc_disk.c&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;#include &amp;#34;tusb.h&amp;#34;
#if CFG_TUD_MSC
enum
{
DISK_BLOCK_NUM = 16, // 8KB
DISK_BLOCK_SIZE = 512
};
#define README_CONTENTS \
&amp;#34;TinyUSB MSC on MM32F0163D7P\r\n\r\n\
CDC + MSC Composite Device Demo&amp;#34;
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
{
// Block0: Boot Sector (FAT12)
{
0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00,
0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, &amp;#39;T&amp;#39; , &amp;#39;i&amp;#39; , &amp;#39;n&amp;#39; , &amp;#39;y&amp;#39; , &amp;#39;U&amp;#39; ,
&amp;#39;S&amp;#39; , &amp;#39;B&amp;#39; , &amp;#39; &amp;#39; , &amp;#39;M&amp;#39; , &amp;#39;S&amp;#39; , &amp;#39;C&amp;#39; , 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA
},
// Block1: FAT12 Table
{
0xF8, 0xFF, 0xFF, 0xFF, 0x0F
},
// Block2: Root Directory
{
&amp;#39;T&amp;#39; , &amp;#39;i&amp;#39; , &amp;#39;n&amp;#39; , &amp;#39;y&amp;#39; , &amp;#39;U&amp;#39; , &amp;#39;S&amp;#39; , &amp;#39;B&amp;#39; , &amp;#39; &amp;#39; , &amp;#39;M&amp;#39; , &amp;#39;S&amp;#39; , &amp;#39;C&amp;#39; , 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
&amp;#39;R&amp;#39; , &amp;#39;E&amp;#39; , &amp;#39;A&amp;#39; , &amp;#39;D&amp;#39; , &amp;#39;M&amp;#39; , &amp;#39;E&amp;#39; , &amp;#39; &amp;#39; , &amp;#39; &amp;#39; , &amp;#39;T&amp;#39; , &amp;#39;X&amp;#39; , &amp;#39;T&amp;#39; , 0x20, 0x00, 0xC6, 0x52, 0x6D,
0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00
},
// Block3: Readme Content
README_CONTENTS
};
uint8_t tud_msc_get_maxlun_cb(void)
{
return 1; // single LUN
}
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4])
{
(void) lun;
const char vid[] = &amp;#34;MM32&amp;#34;;
const char pid[] = &amp;#34;CDC+MSC&amp;#34;;
const char rev[] = &amp;#34;1.0&amp;#34;;
memcpy(vendor_id , vid, strlen(vid));
memcpy(product_id , pid, strlen(pid));
memcpy(product_rev, rev, strlen(rev));
}
bool tud_msc_test_unit_ready_cb(uint8_t lun)
{
(void) lun;
return true;
}
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
{
(void) lun;
*block_count = DISK_BLOCK_NUM;
*block_size = DISK_BLOCK_SIZE;
}
bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
{
(void) lun; (void) power_condition; (void) start; (void) load_eject;
return true;
}
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
(void) lun;
if (lba &amp;gt;= DISK_BLOCK_NUM) return -1;
memcpy(buffer, msc_disk[lba] + offset, bufsize);
return bufsize;
}
bool tud_msc_is_writable_cb(uint8_t lun)
{
(void) lun;
return true;
}
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
{
(void) lun;
if (lba &amp;gt;= DISK_BLOCK_NUM) return -1;
memcpy(msc_disk[lba] + offset, buffer, bufsize);
return bufsize;
}
void tud_msc_eject_cb(uint8_t lun)
{
(void) lun;
}
int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
{
(void) lun; (void) scsi_cmd; (void) buffer;
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
return -1;
}
#endif
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;switch to ARM Compiler 6&lt;/p&gt;</description></item></channel></rss>