主机SPI0无法接收到从机SPI2数据反之能够.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《主机SPI0无法接收到从机SPI2数据反之能够.docx》由会员分享,可在线阅读,更多相关《主机SPI0无法接收到从机SPI2数据反之能够.docx(15页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、主机SPI0无法接收到从机SPI2数据,反之能够file main.c briefSPI fullduplex communication use polling mode version 2017-02-10, V1.0.0, firmware for GD32F30x version 2018-10-10, V1.1.0, firmware for GD32F30x version 2018-12-25, V2.0.0, firmware for GD32F30x version 2020-09-30, V2.1.0, firmware for GD32F30x */* Copyright
2、 (c) 2020, GigaDevice Semiconductor Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
3、disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may
4、be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FI
5、TNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUTNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; O
6、R BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITYOF SUCH DAMAGE.*/#include gd32f30x.h#include gd32f307c_eval.h
7、#define arraysize10#define SET_SPI0_NSS_HIGH gpio_bit_set(GPIOA,GPIO_PIN_4);#define SET_SPI0_NSS_LOWgpio_bit_reset(GPIOA,GPIO_PIN_4);#define SET_SPI2_NSS_HIGH gpio_bit_set(GPIOA,GPIO_PIN_15);#define SET_SPI2_NSS_LOWgpio_bit_reset(GPIOA,GPIO_PIN_15);uint32_t send_n = 0, receive_n = 0;uint8_t spi0_sen
8、d_arrayarraysize = 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA;uint8_t spi2_send_arrayarraysize = 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA;uint8_t spi0_receive_arrayarraysize;uint8_t spi2_receive_arrayarraysize;ErrStatus memory_compare(uint8_t* src, uint8_t* dst, uin
9、t8_t length);void rcu_config(void);void gpio_config(void);void spi_config(void);/*! brief main function paramin none paramout none retvalnone */int main(void) /* init led2 and led3 */ gd_eval_led_init(LED2); gd_eval_led_init(LED3); /* peripheral clock enable */ rcu_config(); /* GPIO config */ gpio_c
10、onfig(); /* SPI config */ spi_config(); SET_SPI0_NSS_HIGH /* SPI enable */ spi_enable(SPI2); spi_enable(SPI0); SET_SPI0_NSS_LOW /* wait for transmit complete */ while(send_n arraysize) while(RESET = spi_i2s_flag_get(SPI2, SPI_FLAG_TBE); spi_i2s_data_transmit(SPI2, A);/spi2_send_arraysend_n); while(R
11、ESET = spi_i2s_flag_get(SPI0, SPI_FLAG_TBE); spi_i2s_data_transmit(SPI0, spi0_send_arraysend_n+); while(RESET = spi_i2s_flag_get(SPI2, SPI_FLAG_RBNE); spi2_receive_arrayreceive_n = spi_i2s_data_receive(SPI2); while(RESET = spi_i2s_flag_get(SPI0, SPI_FLAG_RBNE); spi0_receive_arrayreceive_n+ = spi_i2s
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 主机 SPI0 无法 接收 SPI2 数据 反之 能够
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内