Tidy unused operacake code and use addresses to refer to boards

This commit is contained in:
Dominic Spill
2016-12-25 11:01:55 +00:00
parent c54e31f397
commit b528af46c1
5 changed files with 17 additions and 20 deletions

View File

@ -77,7 +77,7 @@ void operacake_write_reg(i2c_bus_t* const bus, uint8_t address, uint8_t reg, uin
}
uint8_t operacake_init(void) {
int reg, addr, i, j = 0;
uint8_t reg, addr, i, j = 0;
/* Find connected operacakes */
for(i=0; i<8; i++) {
addr = OPERACAKE_DEFAULT_ADDRESS | i;
@ -92,15 +92,6 @@ uint8_t operacake_init(void) {
return 0;
}
// uint8_t operacake_get_boards(uint8_t *boards) {
// int i, j = 0;
// for(i=0; i<8; i++) {
// if(operacake_boards & (1<<i)) {
// ;
// }
// }
// }
uint8_t port_to_pins(uint8_t port) {
switch(port) {
case OPERACAKE_PA1:
@ -124,7 +115,7 @@ uint8_t port_to_pins(uint8_t port) {
return 0xFF;
}
uint8_t operacake_set_ports(uint8_t PA, uint8_t PB) {
uint8_t operacake_set_ports(uint8_t address, uint8_t PA, uint8_t PB) {
uint8_t side, pa, pb, reg;
/* Start with some error checking,
* which should have been done either
@ -149,7 +140,7 @@ uint8_t operacake_set_ports(uint8_t PA, uint8_t PB) {
reg = (OPERACAKE_GPIO_DISABLE | side
| pa | pb | OPERACAKE_EN_LEDS);
operacake_write_reg(oc_bus, 0x00, OPERACAKE_REG_OUTPUT, reg);
operacake_write_reg(oc_bus, address, OPERACAKE_REG_OUTPUT, reg);
return 0;
}

View File

@ -44,7 +44,7 @@ extern "C"
extern uint8_t operacake_boards[8];
uint8_t operacake_init(void);
uint8_t operacake_set_ports(uint8_t PA, uint8_t PB);
uint8_t operacake_set_ports(uint8_t address, uint8_t PA, uint8_t PB);
#ifdef __cplusplus
}

View File

@ -37,8 +37,12 @@ usb_request_status_t usb_vendor_request_operacake_get_boards(
usb_request_status_t usb_vendor_request_operacake_set_ports(
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
{
uint8_t address, port_a, port_b;
address = endpoint->setup.index & 0xFF;
port_a = endpoint->setup.value & 0xFF;
port_b = (endpoint->setup.value >> 8) & 0xFF;
if (stage == USB_TRANSFER_STAGE_SETUP) {
operacake_set_ports(endpoint->setup.index, endpoint->setup.value);
operacake_set_ports(address, port_a, port_b);
usb_transfer_schedule_ack(endpoint->in);
}
return USB_REQUEST_STATUS_OK;

View File

@ -1725,8 +1725,9 @@ int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards)
/* Set Operacake ports */
int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
const uint8_t port_a,
const uint8_t port_b)
uint8_t address,
uint8_t port_a,
uint8_t port_b)
{
int result;
/* Error checking */
@ -1742,8 +1743,8 @@ int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_PORTS,
port_a,
port_b,
address,
port_a | (port_b<<8),
NULL,
0,
0

View File

@ -211,8 +211,9 @@ extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t
/* Operacake functions */
int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards);
int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
const uint8_t port_a,
const uint8_t port_b);
uint8_t address,
uint8_t port_a,
uint8_t port_b);
#ifdef __cplusplus
} // __cplusplus defined.