Initial commit of source code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
22
src/spicmds.c
Normal file
22
src/spicmds.c
Normal file
@@ -0,0 +1,22 @@
|
||||
// Commands for sending messages on an SPI bus
|
||||
//
|
||||
// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "board/gpio.h" // gpio_out_write
|
||||
#include "command.h" // DECL_COMMAND
|
||||
|
||||
void
|
||||
command_send_spi_message(uint32_t *args)
|
||||
{
|
||||
// For now, this only implements enough to program an ad5206 digipot
|
||||
uint8_t len = args[1];
|
||||
char *msg = (void*)(size_t)args[2];
|
||||
spi_config();
|
||||
struct gpio_out pin = gpio_out_setup(args[0], 0);
|
||||
spi_transfer(msg, len);
|
||||
gpio_out_write(pin, 1);
|
||||
sendf("spi_response response=%*s", len, msg);
|
||||
}
|
||||
DECL_COMMAND(command_send_spi_message, "send_spi_message pin=%u msg=%*s");
|
||||
Reference in New Issue
Block a user