kendryte / kendryte-standalone-sdk

Standalone SDK for kendryte K210
https://kendryte.com
Apache License 2.0
445 stars 162 forks source link

SPI slave not work #80

Closed Pillar1989 closed 5 years ago

Pillar1989 commented 5 years ago

BUG REPORT

Expected behavior

Spi slave only use just cs, miso, mosi, clk 4 pins

Actual behavior

Spi slave use just cs, mosi, clk 3 pins and some weird gpio, only accept data, can not send data.

The data is not actually received yet

Test code

#include "spi_slave.h"
#include "fpioa.h"
#include "gpiohs.h"
#include "stdio.h"

#define SPI_SLAVE_INT_PIN       18
#define SPI_SLAVE_INT_IO        4
#define SPI_SLAVE_READY_PIN     19
#define SPI_SLAVE_READY_IO      5
#define SPI_SLAVE_CS_PIN        29
#define SPI_SLAVE_CLK_PIN       28
#define SPI_SLAVE_MOSI_PIN      27
#define SPI_SLAVE_MISO_PIN      21

int spi_slave_receive_hook(void *data){
    printf("%d\n", ((spi_slave_command_t *)data)->err);
    return 0;
}

int spi_slave_init(uint8_t *data, uint32_t len){
    fpioa_set_function(SPI_SLAVE_CS_PIN, FUNC_SPI_SLAVE_SS);
    fpioa_set_function(SPI_SLAVE_CLK_PIN, FUNC_SPI_SLAVE_SCLK);
    fpioa_set_function(SPI_SLAVE_MOSI_PIN, FUNC_SPI_SLAVE_D0);
    fpioa_set_function(SPI_SLAVE_INT_PIN, FUNC_GPIOHS0 + SPI_SLAVE_INT_IO);
    fpioa_set_function(SPI_SLAVE_READY_PIN, FUNC_GPIOHS0 + SPI_SLAVE_READY_IO);
    spi_slave_config(SPI_SLAVE_INT_IO, SPI_SLAVE_READY_IO, DMAC_CHANNEL5, 8, data, len, spi_slave_receive_hook);
    return 0;
}

Document version

https://github.com/kendryte/kendryte-standalone-sdk/releases/tag/V0.5.5

Hardware

Grove AI HAT for Edge Computing

System

What system do you use? Ubuntu 18.04/ windows


FEATURE REQUEST

Missing feature

missing spi slave send data API.

Justification

Simple, only the standard SPI four pin, asynchronous transceiver function.

Workarounds

If I could publish the register manual for the chip, maybe I could share this PR.

xiangbingj commented 5 years ago
  • [x] BUG REPORT
  • [x] FEATURE REQUEST

BUG REPORT

Expected behavior

Spi slave only use just cs, miso, mosi, clk 4 pins

Actual behavior

Spi slave use just cs, mosi, clk 3 pins and some weird gpio, only accept data, can not send data.

The data is not actually received yet

Test code

#include "spi_slave.h"
#include "fpioa.h"
#include "gpiohs.h"
#include "stdio.h"

#define SPI_SLAVE_INT_PIN       18
#define SPI_SLAVE_INT_IO        4
#define SPI_SLAVE_READY_PIN     19
#define SPI_SLAVE_READY_IO      5
#define SPI_SLAVE_CS_PIN        29
#define SPI_SLAVE_CLK_PIN       28
#define SPI_SLAVE_MOSI_PIN      27
#define SPI_SLAVE_MISO_PIN      21

int spi_slave_receive_hook(void *data){
    printf("%d\n", ((spi_slave_command_t *)data)->err);
    return 0;
}

int spi_slave_init(uint8_t *data, uint32_t len){
    fpioa_set_function(SPI_SLAVE_CS_PIN, FUNC_SPI_SLAVE_SS);
    fpioa_set_function(SPI_SLAVE_CLK_PIN, FUNC_SPI_SLAVE_SCLK);
    fpioa_set_function(SPI_SLAVE_MOSI_PIN, FUNC_SPI_SLAVE_D0);
    fpioa_set_function(SPI_SLAVE_INT_PIN, FUNC_GPIOHS0 + SPI_SLAVE_INT_IO);
    fpioa_set_function(SPI_SLAVE_READY_PIN, FUNC_GPIOHS0 + SPI_SLAVE_READY_IO);
    spi_slave_config(SPI_SLAVE_INT_IO, SPI_SLAVE_READY_IO, DMAC_CHANNEL5, 8, data, len, spi_slave_receive_hook);
    return 0;
}

Document version

https://github.com/kendryte/kendryte-standalone-sdk/releases/tag/V0.5.5

Hardware

Grove AI HAT for Edge Computing

System

What system do you use? Ubuntu 18.04/ windows

FEATURE REQUEST

Missing feature

missing spi slave send data API.

Justification

Simple, only the standard SPI four pin, asynchronous transceiver function.

Workarounds

If I could publish the register manual for the chip, maybe I could share this PR.

  1. spi slave mosi and miso share the same pin.
  2. You can refer to the spi slave driver code.The driver performs the operation of sending and receiving data.
xingxingRealzyx commented 5 years ago

solved?

Pillar1989 commented 5 years ago

No, I just don't have time to deal with it

xingxingRealzyx commented 5 years ago

No, I just don't have time to deal with it

Oh, I also encountered the same problem.

NeuerUser commented 3 years ago

Is this bug still existing after 1.5 years or has it been fixed?

firefoxhome commented 3 years ago

Who cares?

------------------ 原始邮件 ------------------ 发件人: "kendryte/kendryte-standalone-sdk" <notifications@github.com>; 发送时间: 2020年12月27日(星期天) 下午2:59 收件人: "kendryte/kendryte-standalone-sdk"<kendryte-standalone-sdk@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: Re: [kendryte/kendryte-standalone-sdk] SPI slave not work (#80)

Is this bug still existing after 1.5 years or has it been fixed?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

NeuerUser commented 3 years ago

Who cares?

Well, I care. I want to use SPI slave to interface a Maix board with a raspberry pi via SPI, the rpi being the master, So, yes, for me I do care if the bug is fixed or not,