From 2b4419ff5ad627637d27dbc1c13391dde09363d0 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Mon, 26 May 2014 02:07:05 +0000 Subject: [PATCH] --- Project/applications/smartcities/i2c.c | 10 +++++++--- Project/applications/smartcities/main2.c | 20 ++++++++++++++++---- Project/applications/smartcities/sensors.c | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Project/applications/smartcities/i2c.c b/Project/applications/smartcities/i2c.c index c872bb2..2441e17 100644 --- a/Project/applications/smartcities/i2c.c +++ b/Project/applications/smartcities/i2c.c @@ -69,7 +69,7 @@ void I2C_start(I2C_TypeDef* I2Cx, uint8_t address, uint8_t direction) void I2C_write(I2C_TypeDef* I2Cx, uint8_t data) { - printf("Sending I2C byte %x...\r\n",data); + printf("Sending I2C byte %02x...\r\n",data); /* WARNING * * OJITO QUE ESTÁ ESPERANDO EL EV8 Y NO EL EV8_2 @@ -91,7 +91,9 @@ uint8_t I2C_read_ack(I2C_TypeDef* I2Cx) { // wait until one byte has been received } - return I2C_ReceiveData(I2Cx); + uint8_t data = I2C_ReceiveData(I2Cx); + printf("Received byte: %02x",data); + return data; } uint8_t I2C_read_nack(I2C_TypeDef* I2Cx) @@ -103,7 +105,9 @@ uint8_t I2C_read_nack(I2C_TypeDef* I2Cx) { // wait until one byte has been received } - return I2C_ReceiveData(I2Cx); + uint8_t data = I2C_ReceiveData(I2Cx); + printf("Received byte: %02x",data); + return data; } void I2C_stop(I2C_TypeDef* I2Cx) diff --git a/Project/applications/smartcities/main2.c b/Project/applications/smartcities/main2.c index 97ca8e6..21f7672 100644 --- a/Project/applications/smartcities/main2.c +++ b/Project/applications/smartcities/main2.c @@ -183,7 +183,8 @@ void wifi_connect(void) void send_battery_level(unsigned long timestamp) { - char *batt_level = battery_value(get_battery_data()); + //char *batt_level = battery_value(get_battery_data()); + char *batt_level = battery_value(3300); char *batt_data = timestamp_data(batt_level,getDate(timestamp)); chHeapFree(batt_level); char *statement = prepare_json_observation_statement(&batt_data,1); @@ -220,11 +221,12 @@ int main(void) char* valueSensors[TOTAL_SENSORS]; memset (valueSensors, 0, TOTAL_SENSORS); - printf("Connecting to wifi...\r\n"); wifi_connect(); - - wakeup_sensors(0x15); + + send_battery_level(getSecsSince1900()); + + wakeup_sensors(0xFF); printf("Scanning sensors...\r\n"); //Escanea y registra I2C_scan(sensors); @@ -349,3 +351,13 @@ int main(void) } } +/* + * TO-DO + * + * - I2C issues + * - Test all sensors + * - Test ADC + * - Network fault tolerance + * - Reset server-related defines + * - Reset timer-related defines + */ \ No newline at end of file diff --git a/Project/applications/smartcities/sensors.c b/Project/applications/smartcities/sensors.c index 4d849b0..50f43cc 100644 --- a/Project/applications/smartcities/sensors.c +++ b/Project/applications/smartcities/sensors.c @@ -24,9 +24,9 @@ void wakeup_sensors(uint8_t logic_address) GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(ADCsound_GPIO_PORT, &GPIO_InitStructure); + GPIO_Init(GPIOA, &GPIO_InitStructure); if(logic_address & 0x1) { -- libgit2 0.22.2