Added multiple device sync

This commit is contained in:
Mike Davis
2016-12-10 01:13:43 +02:00
parent 4a8e3d0d94
commit 242f73efb1
3 changed files with 35 additions and 11 deletions

View File

@ -85,6 +85,11 @@ static struct gpio_t gpio_rffc5072_select = GPIO(2, 13);
static struct gpio_t gpio_rffc5072_clock = GPIO(5, 6);
static struct gpio_t gpio_rffc5072_data = GPIO(3, 3);
static struct gpio_t gpio_rffc5072_reset = GPIO(2, 14);
static struct gpio_t gpio_sync_in_a = GPIO(3, 8);
static struct gpio_t gpio_sync_in_b = GPIO(3, 9);
static struct gpio_t gpio_sync_out_a = GPIO(3, 10);
static struct gpio_t gpio_sync_out_b = GPIO(3, 11);
#endif
/* RF LDO control */
@ -886,3 +891,13 @@ void led_off(const led_t led) {
void led_toggle(const led_t led) {
gpio_toggle(&gpio_led[led]);
}
void hw_sync_start() {
gpio_set(&gpio_sync_out_a);
gpio_set(&gpio_sync_out_b);
}
bool hw_sync_ready() {
return (gpio_read(&gpio_sync_in_a) && gpio_read(&gpio_sync_in_b));
}

View File

@ -271,6 +271,9 @@ void led_on(const led_t led);
void led_off(const led_t led);
void led_toggle(const led_t led);
void hw_sync_start();
bool hw_sync_ready();
#ifdef __cplusplus
}
#endif

View File

@ -203,17 +203,13 @@ void usb_set_descriptor_by_serial_number(void)
usb_descriptor_string_serial_number[2 + i * 2] = c;
usb_descriptor_string_serial_number[3 + i * 2] = 0x00;
}
} else {
} else {
usb_descriptor_string_serial_number[0] = 2;
usb_descriptor_string_serial_number[1] = USB_DESCRIPTOR_TYPE_STRING;
}
}
int main(void) {
struct gpio_t gpio_sync_in = GPIO(3, 11);
struct gpio_t gpio_sync_out_a = GPIO(3, 8);
struct gpio_t gpio_sync_out_b = GPIO(3, 9);
uint8_t usb_dummy_buffer[32768];
for(int i = 0; i < 0x4000; i += 2) {
usb_dummy_buffer[i] = 0xff;
@ -252,7 +248,8 @@ int main(void) {
rf_path_init(&rf_path);
int wait_for_sync_count = 100000000;
bool synced = false;
int hw_sync_count = 0;
unsigned int phase = 0;
while(true) {
@ -261,7 +258,16 @@ int main(void) {
cpld_update();
int gpio_sync_in_flag = gpio_get(gpio_sync_in);
// check for hardware sync
if(hw_sync_ready()) {
synced = true;
hw_sync_start();
} /*else if(hw_sync_count++ > 1000) {
led_toggle(LED3);
hw_sync_count = 0;
}*/
//int gpio_sync_in_flag = gpio_get(gpio_sync_in);
// Set up IN transfer of buffer 0.
if ( usb_bulk_buffer_offset >= 16384
@ -270,7 +276,7 @@ int main(void) {
usb_transfer_schedule_block(
(transceiver_mode() == TRANSCEIVER_MODE_RX)
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
&usb_bulk_buffer[0x0000],
synced ? &usb_bulk_buffer[0x0000] : &usb_dummy_buffer[0x0000],
0x4000,
NULL, NULL
);
@ -284,7 +290,7 @@ int main(void) {
usb_transfer_schedule_block(
(transceiver_mode() == TRANSCEIVER_MODE_RX)
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
&usb_bulk_buffer[0x4000],
synced ? &usb_bulk_buffer[0x4000] : &usb_dummy_buffer[0x4000],
0x4000,
NULL, NULL
);