Started to add some SPI commands
This commit is contained in:
parent
3f0fc680ab
commit
e625328d58
@ -7,6 +7,7 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "wm_gpio_afsel.h"
|
||||||
|
|
||||||
extern int shell_printf(const char *format, ...);
|
extern int shell_printf(const char *format, ...);
|
||||||
extern int wm_printf(const char *fmt,...);
|
extern int wm_printf(const char *fmt,...);
|
||||||
@ -129,6 +130,66 @@ int _reset(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _bus(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||||
|
{
|
||||||
|
if(argc > 1)
|
||||||
|
{
|
||||||
|
if(strcmp(argv[1], "spi_init") == 0)
|
||||||
|
{
|
||||||
|
//Let's set the IO's up
|
||||||
|
wm_spi_cs_config(WM_IO_PB_14);
|
||||||
|
wm_spi_ck_config(WM_IO_PB_15);
|
||||||
|
wm_spi_di_config(WM_IO_PB_16);
|
||||||
|
wm_spi_do_config(WM_IO_PB_17);
|
||||||
|
|
||||||
|
shell_printf("SPI init : %d"NEW_LINE, tls_spi_setup(SPI_DEFAULT_MODE, SPI_CS_ACTIVE_MODE, SPI_DEFAULT_SPEED));
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1], "spi_w") == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1], "spi_r") == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1], "spi_wr") == 0)
|
||||||
|
{
|
||||||
|
char spi_recv_buff[32] = "";
|
||||||
|
/*shell_printf("Writing [%s](len : %d) to SPI"NEW_LINE, argv[2], strlen(argv[2]));
|
||||||
|
if(tls_spi_write((u8*)argv[2], strlen(argv[2])) != TLS_SPI_STATUS_OK)
|
||||||
|
{
|
||||||
|
shell_printf("Failed to write to SPI"NEW_LINE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tls_os_time_delay(1000);*/
|
||||||
|
|
||||||
|
/*if(tls_spi_read((u8*)spi_recv_buff, sizeof(spi_recv_buff) - 1) != TLS_SPI_STATUS_OK)
|
||||||
|
{
|
||||||
|
shell_printf("Failed to read from SPI"NEW_LINE);
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if(tls_spi_read_with_cmd((u8 *) argv[2], strlen(argv[2]), (u8 *) spi_recv_buff, sizeof(spi_recv_buff) - 1) != TLS_SPI_STATUS_OK)
|
||||||
|
{
|
||||||
|
shell_printf("Failed to write & read combo using SPI"NEW_LINE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
shell_printf("Writing [%s](len : %d) to SPI"NEW_LINE, argv[2], strlen(argv[2]));
|
||||||
|
shell_printf("Received [%s](len : %d) from SPI"NEW_LINE, spi_recv_buff, strlen(spi_recv_buff));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shell_printf("List of %s actions :"NEW_LINE"spi_init"NEW_LINE"spi_w"NEW_LINE"spi_r"NEW_LINE"spi_wr"NEW_LINE, argv[0]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int _soft_ap(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
int _soft_ap(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
if(argc > 1)
|
if(argc > 1)
|
||||||
@ -513,6 +574,10 @@ int _exit_remote_access(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NANO_SHELL_ADD_CMD(bus,
|
||||||
|
_bus,
|
||||||
|
"Command to interact with the SPI bus",
|
||||||
|
" Use this command to send/receive data from the SPI bus"NEW_LINE);
|
||||||
NANO_SHELL_ADD_CMD(system,
|
NANO_SHELL_ADD_CMD(system,
|
||||||
_system,
|
_system,
|
||||||
"Query system information",
|
"Query system information",
|
||||||
|
Loading…
Reference in New Issue
Block a user