完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我遵循了示例:20719-B1BLASBApple Snip HalSpmithMead来创建与3轴G传感器的SPI通信。但我发现,SypCCS会过早返回不活跃,这将导致错误的书写操作。. 我还用PSoC6做同样的事情,PSoC6做得很好: 这些代码: 空缺单位() { WieDeHalpIpSmith-IIT(SPIGH-Prima,IputoPixPull),MaskP38,CKLYP28,MsisiP01MISO,DefftTyf频率,SPIMSMSBY第一,SpIsSSa Acthvivin低,SmithMODE3,SPILCS); } 空sDENDATA数据(无符号字符寄存器地址,无符号char值,无符号字符数,字节) { 无符号Chan-SeunthDATA〔2〕; 无符号Car ReCiDATA数据〔8〕; 如果(1)!= WiDeEdBTyTracle(“McBeBeRead Read字节错误=%Drn”,NothByOx字节);} WiDeEdBTyTrue(“WR:Re= 0x%02x,Value=0x%02xrn”,RealStistAdvor,*值);SDENDATA数据[0 ] = RealStIdAcess地址0x40;// 1字节;写操作sEndoDATA(1)=*值; WieDeHalpHpSPixExchange数据(SIEZOF(SDENDATA DATA),SDENDATA数据,ReCiDATA数据); } 另一个问题是,由于SPIX是由SPI驱动程序自动控制的,为什么样本代码写有红色代码? … WICDEDHALLGPIOOXCONTIOURION PIN(CS,GPIOOXOUTPUTION启用,GPIOOPIN PUTIOUTPUPHIGH); WieDe- HalypPiSmithIIT(SmithMault,IputoPixPulLyUp,MaskP38,CKLYP28,MsisiaP01MISO,DeultTyffi频率,SPILL LSBBY第一,SpIsSSa Acthvivin低,SpxMod E0,CS); … WICEDH-HalgGiooSoToPixPin输出(CS,GPIOI PixOutPutsPHILL); WIDEDHALHSPISPIXTXII数据(SIZEOF(START字节),和SAMDSPION字节); WICEDH-HalgGiooSeToPixPin输出(CS,GPIOI PixOutPuthoHig); … WICEDDY-RoTyth-Delay-MyLimeSDS(20, 1);WICDEDHALGIGPIOSSETION Pin输出(CS,GPIOOPIN OUTPUTPUTHOLL);WICDEDHALL PSPIXRXII数据(SIZEOF(ReCyByb),ReCyByb);WieDeHalg-GPIOOSSETION Pin输出(CS,GPIOI PixOutPuthPHIGH); … 以上来自于百度翻译 以下为原文 Hi, I followed the example : 20719-B1_Bluetoothappssniphalspi_master to create a SPI communication with a 3-axis g-sensor. But I found the SPI_CS will back to inactive too early that will cause an incorrect Writing operation. . I also used PSOC6 to do the same thing, and PSOC6 did very well: These r the codes: void init_spi() { wiced_hal_pspi_init(SPI_MASTER, INPUT_PIN_PULL_DOWN, MASTER_P38_CLK_P28_MOSI_P01_MISO, DEFAULT_FREQUENCY, SPI_MSB_FIRST, SPI_SS_ACTIVE_LOW, SPI_MODE_3, SPI_CS); } void send_data(unsigned char register_address, unsigned char *value, unsigned char number_of_bytes) { unsigned char send_data[2]; unsigned char rec_data[8]; if( 1!= number_of_bytes ) { WICED_BT_TRACE("mcube_read_regs bytes error =%drn", number_of_bytes); } WICED_BT_TRACE("WR: reg = 0x%02x, value = 0x%02xrn", register_address, *value); send_data[0] = register_address |0x40; // 1 bytes; write operation send_data[1] = *value; wiced_hal_pspi_exchange_data(sizeof(send_data), send_data, rec_data); } Another question is, Since the SPI_CS is controlled by SPI driver automatically, why the sample code write there red codes? .... wiced_hal_gpio_configure_pin(CS, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH); wiced_hal_pspi_init(SPI_MASTER, INPUT_PIN_PULL_UP, MASTER_P38_CLK_P28_MOSI_P01_MISO, DEFAULT_FREQUENCY, SPI_LSB_FIRST, SPI_SS_ACTIVE_LOW, SPI_MODE_0, CS); .... wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_LOW); wiced_hal_pspi_tx_data(sizeof(start_byte), &start_byte); wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_HIGH); ..... wiced_rtos_delay_milliseconds(20, 1); wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_LOW); wiced_hal_pspi_rx_data(sizeof(rec_byte), rec_byte); wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_HIGH); .... |
|
相关推荐
7个回答
|
|
你好,
CS引脚被控制为GPIO,您可以尝试添加一些延迟,然后将CS引脚设置为高状态。 以上来自于百度翻译 以下为原文 Hi, The cs pin is controlled as GPIO, you can just try to add some delay before you set the cs pin to high state. |
|
|
|
你好,ZHXH, CS不是GPIO, 1。在销钉配置为SPICOS之后,CS不能由WICEDH-HalgGPIOSSETION Pin输出控制(CS,GPIOOPIN PosiOutPutsILL); C.T.F. { [ PrpFultGPIOO00]={WICEDEXP00,WICEDEXGPIO },//按钮 [ PrimthgGPIOHY1]={WICEDEXP01,WICEDEDSPILY1LISMO }, [ PrimthgGPIOI2] = {WICEDEXP02,WICEDEXPCMYOUTII2SYDO }, [ PrimthgGPIOHY3]={ WICEDEXP04,WICEDEXPCMIN III2SYDI}, [ PrimthgGPIOHY4]={WICEDEXP06,WICEDEXGPIO}, [ PrpulthGPIOHY5]={WICEDEXP07,WICEDED SPILY1CCS }, … WieDeHalpIpSmith-IIT(SPIGH-Prima,IputoPixPull),MaskP38,CKLYP28,MsisiP01MISO,DefftTyf频率,SPIMSMSBY第一,SpIsSSa Acthvivin低,SmithMODE3,SPILCS); 必须: WieDeHalgGioOx选择函数(SPIKS CS,WICEDESGPIO) WICDEDHALLGPIOOXCONTIOURION PIN(SPIOCS CS,GPIOOXOUTPUTION启用,GPIOOPIN PUTIOUTPUPHIGH); 然后你可以设置PIN(SPILCS)。 2。即使你注释这些代码,SPICOS也会自动地写下或读取操作。 WICDEDHALLGPIOOXCONTIOURION PIN(SPIOCS CS,GPIOOXOUTPUTION启用,GPIOOPIN PUTIOUTPUPHIGH); WICEDH-HalgGiooSoToPixPin输出(CS,GPIOI PixOutPutsPHILL); WICEDH-HalgGiooSeToPixPin输出(CS,GPIOI PixOutPuthoHig); 以上来自于百度翻译 以下为原文 Hi zhxh, CS is not a GPIO, 1. After the PIN configured to SPI_CS, the CS cannot be controlled by wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_LOW); const wiced_platform_gpio_t platform_gpio_pins[] = { [PLATFORM_GPIO_0 ] = {WICED_P00, WICED_GPIO }, //Button [PLATFORM_GPIO_1 ] = {WICED_P01, WICED_SPI_1_MISO }, [PLATFORM_GPIO_2 ] = {WICED_P02, WICED_PCM_OUT_I2S_DO }, [PLATFORM_GPIO_3 ] = {WICED_P04, WICED_PCM_IN_I2S_DI }, [PLATFORM_GPIO_4 ] = {WICED_P06, WICED_GPIO }, [PLATFORM_GPIO_5 ] = {WICED_P07, WICED_SPI_1_CS }, ..... wiced_hal_pspi_init(SPI_MASTER, INPUT_PIN_PULL_DOWN, MASTER_P38_CLK_P28_MOSI_P01_MISO, DEFAULT_FREQUENCY, SPI_MSB_FIRST, SPI_SS_ACTIVE_LOW, SPI_MODE_3, SPI_CS); MUST: wiced_hal_gpio_select_function(SPI_CS, WICED_GPIO), wiced_hal_gpio_configure_pin(SPI_CS, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH); then you can set pin (SPI_CS). 2. The SPI_CS will go HIGH /LOW automatically while writing or reading operation even if you comment out these code: wiced_hal_gpio_configure_pin(SPI_CS, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH); wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_LOW); wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_HIGH); |
|
|
|
otinn 发表于 2018-9-20 11:47 兰姆 请你看看这个好吗? 以上来自于百度翻译 以下为原文 ranm Could you take a look at this please? |
|
|
|
otinn 发表于 2018-9-20 11:47 你好, 您需要编辑/20719-B1BLoBLooS/Staly/CyW920719Q40EVB01/WICDEDPPLAMFILL PNION CONFIG.C文件,如下所示(突出显示的文本) 当前代码: C.T.F. { [ PrpFultGPIOO00]={WICEDEXP00,WICEDEXGPIO },//按钮 [ PrimthgGPIOHY1]={WICEDEXP01,WICEDEDSPILY1LISMO }, [ PrimthgGPIOI2] = {WICEDEXP02,WICEDEXPCMYOUTII2SYDO }, [ PrimthgGPIOHY3]={ WICEDEXP04,WICEDEXPCMIN III2SYDI}, [ PrimthgGPIOHY4]={WICEDEXP06,WICEDEGGCIIGPIO060}, [ PrpulthGPIOHY5]={WICEDEXP07,WICEDED SPILY1CCS }, [ PrimthgGPIOHY6]={WICEDEXP10,WICEDEGGCIIGPIO070}, [ PrimthgGPIOO7]={WICEDEXP16,WICDEDH-PCMY-CKKY-I2SY-CLK}, [ PrimthgGPIOHY8]={WICEDEXP17,WICEDEXPCMYSycCiI2SyWS}, [ PrpultGPIOO99]={WICEDEXP26,WICEDEXGPIO },//默认LED 2 [ PrimthgGPIOO10]={WICEDEXP25,WICDEDII2CY1YSSCL}, [ PrpultGPIOOY11]={WICEDEXP28,WICEDED SPILY1MYSI},/ /可选LED 1 [ PrimthgGPIOHY12]={WICEDEXP29,WICDEDII2CY11SDA }, [ PrimthgGPIOO13] = {WICEDEXP33,WICDEDU-ARARTY2LXTXD}, [ PrimthgGPIOO14] = {WICEDEXP34,WICDEDU-ARARTY2RXXD}, [ PrimthgGPIOI15]={WICEDEXP38,WICEDEXSPILY1KLK}, }; 新代码: C.T.F. { [ PrpFultGPIOO00]={WICEDEXP00,WICEDEXGPIO },//按钮 [ PrimthgGPIOHY1]={WICEDEXP01,WICEDEDSPILY1LISMO }, [ PrimthgGPIOI2] = {WICEDEXP02,WICEDEXPCMYOUTII2SYDO }, [ PrimthgGPIOHY3]={ WICEDEXP04,WICEDEXPCMIN III2SYDI}, [ PrimthgGPIOHY4]={WICEDEXP06,WICEDEGGCIIGPIO060}, [ PrpultGPIOIO5]={WICEDEXP07,WICEDEXGPIO}, [ PrimthgGPIOHY6]={WICEDEXP10,WICEDEGGCIIGPIO070}, [ PrimthgGPIOO7]={WICEDEXP16,WICDEDH-PCMY-CKKY-I2SY-CLK}, [ PrimthgGPIOHY8]={WICEDEXP17,WICEDEXPCMYSycCiI2SyWS}, [ PrpultGPIOO99]={WICEDEXP26,WICEDEXGPIO },//默认LED 2 [ PrimthgGPIOO10]={WICEDEXP25,WICDEDII2CY1YSSCL}, [ PrpultGPIOOY11]={WICEDEXP28,WICEDED SPILY1MYSI},/ /可选LED 1 [ PrimthgGPIOHY12]={WICEDEXP29,WICDEDII2CY11SDA }, [ PrimthgGPIOO13] = {WICEDEXP33,WICDEDU-ARARTY2LXTXD}, [ PrimthgGPIOO14] = {WICEDEXP34,WICDEDU-ARARTY2RXXD}, [ PrimthgGPIOI15]={WICEDEXP38,WICEDEXSPILY1KLK}, }; 然后你可以控制你的应用程序中的CS PIN。 在使用SPI作为主机时应使用此配置。当使用SPI作为从属时,CS引脚应该连接到SPI块(如在默认代码中) 谢谢 阿披实 以上来自于百度翻译 以下为原文 Hi, You need to edit the /20719-B1_Bluetooth/platforms/CYW920719Q40EVB_01/wiced_platform_pin_config.c file as follows (Highlighted text) Current code: const wiced_platform_gpio_t platform_gpio_pins[] = { [PLATFORM_GPIO_0 ] = {WICED_P00, WICED_GPIO }, //Button [PLATFORM_GPIO_1 ] = {WICED_P01, WICED_SPI_1_MISO }, [PLATFORM_GPIO_2 ] = {WICED_P02, WICED_PCM_OUT_I2S_DO }, [PLATFORM_GPIO_3 ] = {WICED_P04, WICED_PCM_IN_I2S_DI }, [PLATFORM_GPIO_4 ] = {WICED_P06, WICED_GCI_GPIO_06 }, [PLATFORM_GPIO_5 ] = {WICED_P07, WICED_SPI_1_CS }, [PLATFORM_GPIO_6 ] = {WICED_P10, WICED_GCI_GPIO_07 }, [PLATFORM_GPIO_7 ] = {WICED_P16, WICED_PCM_CLK_I2S_CLK }, [PLATFORM_GPIO_8 ] = {WICED_P17, WICED_PCM_SYNC_I2S_WS }, [PLATFORM_GPIO_9 ] = {WICED_P26, WICED_GPIO }, //Default LED 2 [PLATFORM_GPIO_10] = {WICED_P25, WICED_I2C_1_SCL }, [PLATFORM_GPIO_11] = {WICED_P28, WICED_SPI_1_MOSI }, //Optional LED 1 [PLATFORM_GPIO_12] = {WICED_P29, WICED_I2C_1_SDA }, [PLATFORM_GPIO_13] = {WICED_P33, WICED_UART_2_TXD }, [PLATFORM_GPIO_14] = {WICED_P34, WICED_UART_2_RXD }, [PLATFORM_GPIO_15] = {WICED_P38, WICED_SPI_1_CLK }, }; New Code: const wiced_platform_gpio_t platform_gpio_pins[] = { [PLATFORM_GPIO_0 ] = {WICED_P00, WICED_GPIO }, //Button [PLATFORM_GPIO_1 ] = {WICED_P01, WICED_SPI_1_MISO }, [PLATFORM_GPIO_2 ] = {WICED_P02, WICED_PCM_OUT_I2S_DO }, [PLATFORM_GPIO_3 ] = {WICED_P04, WICED_PCM_IN_I2S_DI }, [PLATFORM_GPIO_4 ] = {WICED_P06, WICED_GCI_GPIO_06 }, [PLATFORM_GPIO_5 ] = {WICED_P07, WICED_GPIO }, [PLATFORM_GPIO_6 ] = {WICED_P10, WICED_GCI_GPIO_07 }, [PLATFORM_GPIO_7 ] = {WICED_P16, WICED_PCM_CLK_I2S_CLK }, [PLATFORM_GPIO_8 ] = {WICED_P17, WICED_PCM_SYNC_I2S_WS }, [PLATFORM_GPIO_9 ] = {WICED_P26, WICED_GPIO }, //Default LED 2 [PLATFORM_GPIO_10] = {WICED_P25, WICED_I2C_1_SCL }, [PLATFORM_GPIO_11] = {WICED_P28, WICED_SPI_1_MOSI }, //Optional LED 1 [PLATFORM_GPIO_12] = {WICED_P29, WICED_I2C_1_SDA }, [PLATFORM_GPIO_13] = {WICED_P33, WICED_UART_2_TXD }, [PLATFORM_GPIO_14] = {WICED_P34, WICED_UART_2_RXD }, [PLATFORM_GPIO_15] = {WICED_P38, WICED_SPI_1_CLK }, }; Then you can control the CS pin in your application. This configuration should be used while using SPI as a master. When using SPI as a slave the CS pin should be connected to the SPI block (like in the default code) Thanks Abhishek |
|
|
|
shensi72 发表于 2018-9-20 12:04 嗨,安卡, 是的,我可以使用GPIOSSEPTION函数、CONTIONPIN和StIGOULPUT来改变SPIGCS到GPIO。 但是写作操作仍然没有达到预期的效果。 我必须设置引脚(MOSI/MISO/CLK/CS)到GPIOX模拟器,同时写,它的工作!. 以上来自于百度翻译 以下为原文 Hi amka, Yes, I can change SPI_CS to GPIO use gpio_select_function, config_pin, and then set_ouput also . But writing operation still not work as expected. I have to set pins(MOSI/MISO/CLK/CS) to GPIO_SIMULATOR while writing, and it works!. |
|
|
|
otinn 发表于 2018-9-20 12:14 我可以问一下I2C问题吗? 在示例代码中,I2C3Mealth.C: I2CMIN(); 如果(I2CM.COM)((UTI8*)和数据,SIEZOF(UIT8),和ReGyAdd,SIZEOF(UIT8),LSM9DS1A ACCHIGROY-I2CX地址) 我找不到这两个函数定义或原型。但它可以编译和运行良好。 我的问题是,如何写作? 以上来自于百度翻译 以下为原文 May I ask I2C question here ? in the sample code, I2C_MASTER.c : i2cm_init(); if((i2cm_comboRead((UINT8 *)&data, sizeof(UINT8), ®_add, sizeof(UINT8), LSM9DS1_ACC_GYRO_I2C_ADDRESS))) I cannot find these two functions Definition or Prototype. But it can compile and running well. My question is , how to write ? |
|
|
|
林浙28 61801 这是一个内部API。Wice 6.2已经用WiDDyHalthi2CcMuleDyAdRead替换了这个API。更新您的WWEL到最新版本,您将能够看到这个新的API 以上来自于百度翻译 以下为原文 linzh_2861801 This was an internal API. WICED 6.2 has replaced this API with wiced_hal_i2c_combined_read. Update your WICED to the latest version and you will be able to see this new API |
|
|
|
只有小组成员才能发言,加入小组>>
740个成员聚集在这个小组
加入小组1980 浏览 1 评论
1735 浏览 1 评论
3507 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1667 浏览 6 评论
1447 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
215浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
122浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
323浏览 2评论
271浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
455浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-18 23:01 , Processed in 0.842876 second(s), Total 58, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191