Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void transfer(int fd)
- {
- /*Just try and read the JEDEC ID from the SPI NOR flash for now*/
- int ret;
- uint8_t tx[20] = {RDID,};
- uint8_t rx[20] = {0,};
- struct spi_ioc_transfer trans;
- memset(&trans, 0, sizeof(struct spi_ioc_transfer));
- trans.tx_buf = (unsigned long)tx;
- trans.rx_buf = (unsigned long)rx;
- trans.len = ARRAY_SIZE(tx);
- trans.delay_usecs = delay;
- trans.speed_hz = speed;
- trans.bits_per_word = bits;
- trans.cs_change = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &trans);
- if (ret < 1) {
- pabort("failed to send spi message");
- }
- for (ret = 0; ret < ARRAY_SIZE(rx); ret++) {
- if (!(ret % 6)) {
- puts("");
- }
- printf("%.2X ", rx[ret]);
- }
- puts("");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement