kendryte / kendryte-standalone-demo

Demo of kendryte k210 standalone SDK
https://github.com/kendryte/kendryte-standalone-sdk
229 stars 97 forks source link

SPI slave not work #27

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.

Pillar1989 commented 5 years ago

It is more appropriate to put the issye here https://github.com/kendryte/kendryte-standalone-sdk/issues/80