共2条
1/1 1 跳转至页
MSP430 MSP430的代码指针怎么使用?
问
定义了一个常量结构,想用指针的方式使用,不知如何使用?C51中可以定义指针的存储器类型,而MSP的C430中却没有!请高手赐教!谢谢!
答 1:
const uchar string[]={"abcdefghijk\n"};
uchar *pointer;
pointer=&string[]; 答 2: 在C51中:
1)结构定义:
typedef struct _USB_DEVICE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
USHORT idVendor;
USHORT idProduct;
USHORT bcdDevice;
UCHAR iManufacturer;
UCHAR iProduct;
UCHAR iSerialNumber;
UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
结构常量:(里边全部是常量)
code USB_DEVICE_DESCRIPTOR DeviceDescr =
{
sizeof(USB_DEVICE_DESCRIPTOR),
USB_DEVICE_DESCRIPTOR_TYPE,
SWAP(0x0110),
USB_CLASS_CODE_TEST_CLASS_DEVICE,
0, 0,
EP0_PACKET_SIZE,
SWAP(0x0471),
SWAP(0x0666),
SWAP(0x0100),
0, 0, 0,
1
};
函数定义:
//发送端点号1建立代码
void code_transmit(unsigned char code * pRomData, unsigned short len)
{
ControlData.wCount = 0;
if(ControlData.wLength > len) ControlData.wLength = len;
ControlData.pData = pRomData;
D12_WriteEndpoint(1, EP0_PACKET_SIZE, ControlData.pData);//发送16字节数据
ControlData.wCount += EP0_PACKET_SIZE;
}
}
函数调用:
code_transmit((unsigned char code *)&DeviceDescr, sizeof(USB_DEVICE_DESCRIPTOR));
请问在MSP的C430中怎么移植?我将以上代码的code改为const编译是通不过的!谢谢赐教!
uchar *pointer;
pointer=&string[]; 答 2: 在C51中:
1)结构定义:
typedef struct _USB_DEVICE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
USHORT idVendor;
USHORT idProduct;
USHORT bcdDevice;
UCHAR iManufacturer;
UCHAR iProduct;
UCHAR iSerialNumber;
UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
结构常量:(里边全部是常量)
code USB_DEVICE_DESCRIPTOR DeviceDescr =
{
sizeof(USB_DEVICE_DESCRIPTOR),
USB_DEVICE_DESCRIPTOR_TYPE,
SWAP(0x0110),
USB_CLASS_CODE_TEST_CLASS_DEVICE,
0, 0,
EP0_PACKET_SIZE,
SWAP(0x0471),
SWAP(0x0666),
SWAP(0x0100),
0, 0, 0,
1
};
函数定义:
//发送端点号1建立代码
void code_transmit(unsigned char code * pRomData, unsigned short len)
{
ControlData.wCount = 0;
if(ControlData.wLength > len) ControlData.wLength = len;
ControlData.pData = pRomData;
D12_WriteEndpoint(1, EP0_PACKET_SIZE, ControlData.pData);//发送16字节数据
ControlData.wCount += EP0_PACKET_SIZE;
}
}
函数调用:
code_transmit((unsigned char code *)&DeviceDescr, sizeof(USB_DEVICE_DESCRIPTOR));
请问在MSP的C430中怎么移植?我将以上代码的code改为const编译是通不过的!谢谢赐教!
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |