diff --git a/DSTAT-temp/src/ads1255.c b/DSTAT-temp/src/ads1255.c index da80579ace3303be0fb5b9d458542e242573bb31..3c92ba9575914de99e5dd029af3e26e198884aa6 100644 --- a/DSTAT-temp/src/ads1255.c +++ b/DSTAT-temp/src/ads1255.c @@ -22,20 +22,11 @@ void ads1255_init_pins(void) arch_ioport_set_port_level(IOPORT_PORTE, PIN4_bm|PIN5_bm|PIN7_bm, PIN4_bm|PIN7_bm); arch_ioport_set_pin_dir(IOPORT_CREATE_PIN(PORTD,5), IOPORT_DIR_INPUT); arch_ioport_set_pin_sense_mode(IOPORT_CREATE_PIN(PORTD,5), IOPORT_SENSE_FALLING); - -// ioport_configure_port_pin(&PORTE, PIN4_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTE, PIN5_bm, IOPORT_INIT_LOW | IOPORT_DIR_OUTPUT); -// ioport_configure_port_pin(&PORTE, PIN6_bm, IOPORT_DIR_INPUT); -// ioport_configure_port_pin(&PORTE, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); - //DRDY -// ioport_configure_port_pin(&PORTE, PIN3_bm, IOPORT_DIR_INPUT | IOPORT_FALLING); v1 Board -// ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_DIR_INPUT | IOPORT_FALLING); } - - void ads1255_init_module(void){ +void ads1255_init_module(void){ usart_spi_init(&USARTE1); - usart_spi_setup_device(&USARTE1, &spi_device_conf, SPI_MODE_1, 1900000UL, 0);// + usart_spi_setup_device(&USARTE1, &spi_device_conf, SPI_MODE_1, 1900000UL, 0); } void ads1255_sync(void){ @@ -54,7 +45,6 @@ void ads1255_reg_read(uint8_t address){ usart_spi_select_device(&USARTE1, &spi_device_conf); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))) usart_spi_write_packet(&USARTE1, &(command_buffer[0]), 2); @@ -70,7 +60,7 @@ void ads1255_reg_read(uint8_t address){ void ads1255_reset(){ usart_spi_select_device(&USARTE1, &spi_device_conf); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); + while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); usart_spi_transmit(&USARTE1, ADS_RESET); @@ -79,7 +69,6 @@ void ads1255_reset(){ printf("ADS1255: Waiting for calibration\n\r"); #endif -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); usart_spi_deselect_device(&USARTE1, &spi_device_conf); @@ -158,7 +147,7 @@ void ads1255_setup(uint8_t buff, uint8_t rate, uint8_t pga){ usart_spi_write_packet(&USARTE1, (uint8_t*)&command_buffer, 6); usart_spi_transmit(&USARTE1, ADS_SYNC); usart_spi_transmit(&USARTE1, ADS_SELFCAL); -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); + while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))) ; usart_spi_deselect_device(&USARTE1, &spi_device_conf); @@ -203,8 +192,7 @@ void ads1255_wakeup(void){ void ads1255_rdatac(void){ usart_spi_select_device(&USARTE1, &spi_device_conf); usart_spi_transmit(&USARTE1, ADS_RDATAC); - -// while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); + while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))) ; usart_spi_deselect_device(&USARTE1, &spi_device_conf); @@ -302,7 +290,6 @@ int32_t ads1255_read_fast24(void){ else 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); return input_buffer.int32; } diff --git a/DSTAT-temp/src/main.c b/DSTAT-temp/src/main.c index 14c3156ea55c4eea725cc98e379ab3115f59dc60..af0043a933d575ae8d2cbc493c55f60d948847df 100644 --- a/DSTAT-temp/src/main.c +++ b/DSTAT-temp/src/main.c @@ -12,8 +12,6 @@ int16_t p1, p2, p3, p4; uint16_t u1, u2, u3, u4; uint8_t p5, o1, o2, o3; -//uint16_t step_dac[50], step_seconds[50]; - //Internal function declarations int8_t command_handler(char command); @@ -134,22 +132,20 @@ int main(void){ pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN); + delay_ms(500); + stdio_usb_init(); stdio_usb_enable(); ads1255_init_pins(); ads1255_init_module(); - ads1255_setup(ADS_BUFF_ON,ADS_DR_60,ADS_PGA_2); PORTD.INT0MASK = PIN5_bm; PORTD.INT1MASK = PIN5_bm; PORTD.INTCTRL = PORT_INT0LVL_OFF_gc | PORT_INT1LVL_OFF_gc; - dma_enable(); - max5443_init_pins(); max5443_init_module(); - delay_ms(300); ads1255_wakeup(); ads1255_rdatac(); diff --git a/DSTAT1.atsuo b/DSTAT1.atsuo index 4d502164b15ef896773355c66b2977e4db83774e..27e605a947380e8b305f257e7b61f155ff94837d 100644 Binary files a/DSTAT1.atsuo and b/DSTAT1.atsuo differ