Skip to content
Snippets Groups Projects
Commit a406a2b9 authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Binary data transfer for CA implemented.

parent 1372fa34
No related merge requests found
......@@ -325,9 +325,9 @@ int32_t ads1255_read_fast24(void){
usart_spi_deselect_device(&USARTE1, &spi_device_conf);
if (input_buffer.uint[2] > 0x7F)
input_buffer.uint[3] = 0xFF;
input_buffer.uint[3] = 0xFF;
else
input_buffer.uint[3] = 0x0;
input_buffer.uint[3] = 0x0;
// printf("%x %x %x\n\r", input_buffer.uint[2],input_buffer.uint[1], input_buffer.uint[0]);
cpu_irq_restore(flags);
......
......@@ -47,6 +47,29 @@ typedef void (*port_callback_t) (void);
static port_callback_t portd_int0_callback;
static port_callback_t portd_int1_callback;
void send_data_uint16(uint16_t data){
/**
* Sends uint16 data over USB in order in memory (should be LSB first for AVR - little endian)
*
* @param data 16-bit data
* @return Nothing.
*/
udi_cdc_putc(((unsigned char *)(&data))[0]);
udi_cdc_putc(((unsigned char *)(&data))[1]);
}
void send_data_int32(int32_t data){
/**
* Sends int32 data over USB in order in memory (should be LSB first for AVR - little endian)
*
* @param data 32-bit data
* @return Nothing.
*/
udi_cdc_putc(((unsigned char *)(&data))[0]);
udi_cdc_putc(((unsigned char *)(&data))[1]);
udi_cdc_putc(((unsigned char *)(&data))[2]);
udi_cdc_putc(((unsigned char *)(&data))[3]);
}
void pot_init(void){
/**
* Initializes AVR port directions and levels
......@@ -487,7 +510,12 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[])
}
static void portd_int0_ca(void){
printf("%u.%.3u %ld\n\r", TCC0.CNT, RTC.CNT, ads1255_read_fast24());
printf("B\n");
send_data_uint16(TCC0.CNT);
send_data_uint16(RTC.CNT);
send_data_int32(ads1255_read_fast24());
printf("\n");
// printf("%u.%.3u %ld\n\r", TCC0.CNT, RTC.CNT, ads1255_read_fast24());
}
static void ca_cca_callback(void){
......
......@@ -56,6 +56,8 @@
extern uint16_t g_gain;
extern uint8_t autogain_enable;
void send_data_uint16(uint16_t data);
void send_data_int32(int32_t data);
void pot_init(void);
int8_t autogainswitch(void);
void pot_set_gain(void);
......
No preview for this file type
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment