Skip to content
Snippets Groups Projects
Commit 7e17ca28 authored by Leonardo Martinez Hornak's avatar Leonardo Martinez Hornak
Browse files

Merge with firmware_leo

parents 5502dbd4 f96257cf
Branches
Tags interim_RC_1
No related merge requests found
......@@ -94,11 +94,31 @@ void initializeSen15219(void);
void readSamples(void);
/**
* @brief Function used to get led raw data from the queues.
* @brief Function used to get led raw data from the queues
* @param int* led_ir: IR led data returned by reference
* @param int* led_ir: IR led data returned by reference
* @return char: returns 1 if data is available and returned by reference
*/
char getLedsRawData(int* led_ir, int* led_red);
/**
* @brief Function used to get confidence level value
* @return int: returns confidence level from 0 to 100%
*/
int getConfidenceLevel(void);
/**
* @brief Function used to get heart rate value
* @return int: returns 10 x heart rate value in bpm
*/
int getHeartRate(void);
/**
* @brief Function used to get oxygen saturation value
* @return int: returns 10 x SpO2 value in %
*/
int getOxygenSaturation(void);
void testQueue(void);
#endif /* INCLUDE_SEN_15219_H_ */
......@@ -40,38 +40,38 @@ void initializeCommunications(void)
void sendProcessedValues(void)
{
//TODO Adjust to what will be obtained from SEN-15219
int raw_value, i;
int aux, i;
tx_buffer_bluetooth[0] = START_CHARACTER_PROCESSED;
tx_buffer_bluetooth[1] = 7;
tx_buffer_bluetooth[1] = 9;
tx_buffer_bluetooth[2] = (char)getLastTemperatureReading();
//Heart Rate
raw_value = 180;
tx_buffer_bluetooth[3] = (char)(raw_value & 0xFF);
aux = getHeartRate();
tx_buffer_bluetooth[3] = (char)((aux & 0xFF00) >> 8);
tx_buffer_bluetooth[4] = (char)(aux & 0xFF);
//SpO2
raw_value = 90;
tx_buffer_bluetooth[4] = (char)(raw_value & 0xFF);
aux = getOxygenSaturation();
tx_buffer_bluetooth[5] = (char)((aux & 0xFF00) >> 8);
tx_buffer_bluetooth[6] = (char)(aux & 0xFF);
//Confidence Level
raw_value = 50;
tx_buffer_bluetooth[5] = (char)(raw_value & 0xFF);
tx_buffer_bluetooth[7] = (char)(getConfidenceLevel() & 0xFF);
//Respiration
raw_value = 12;
tx_buffer_bluetooth[6] = (char)(raw_value & 0xFF);
aux = 12;
tx_buffer_bluetooth[8] = (char)(aux & 0xFF);
tx_buffer_bluetooth[7] = tx_buffer_bluetooth[0];
for(i=0; i< 6; i++)
tx_buffer_bluetooth[9] = tx_buffer_bluetooth[0];
for(i=0; i< 8; i++)
{
tx_buffer_bluetooth[7] ^= tx_buffer_bluetooth[1 + i];
tx_buffer_bluetooth[9] ^= tx_buffer_bluetooth[1 + i];
}
tx_buffer_bluetooth[8] = END_CHARACTER;
tx_buffer_bluetooth[10] = END_CHARACTER;
uartBluetoothTransmit(&tx_buffer_bluetooth[0], 9);
uartBluetoothTransmit(&tx_buffer_bluetooth[0], 11);
}
void sendRawValues(void)
......
......@@ -44,7 +44,7 @@ void initializeGPIOModule(void)
//Set P6.4 MFIO and P6.5 RSTN as output
P6DIR = 0xFF;
P6OUT = 0;
P6OUT = 1;
P6SEL1 = 0;
P6SEL0 = 0;
......@@ -101,12 +101,12 @@ void setSEN15219MFIOCallbackFunction(void *callback_function)
void enterAppModeSEN15219(void)
{
P6OUT &= ~BIT5; //RST LOW for 10 ms
P6OUT &= ~BIT0; //RST LOW for 10 ms
waitMilliseconds(1);
P6OUT |= BIT4; //Pull MFIO high
waitMilliseconds(9);
P6OUT |= BIT5; //Pull RST High
P6OUT |= BIT0; //Pull RST High
//After 1 second, the device is ready to accept i2c commands
waitMilliseconds(1000);
......
......@@ -85,7 +85,7 @@ void initializeSen15219(void)
hub_status = HUB_STATUS_UNKNOWN_ERROR;
//Device Start-up
waitMilliseconds(INIT_DELAY_SEN15219);;
waitMilliseconds(INIT_DELAY_SEN15219);
}
//This function is called from MFIO ISR when new data is available in the MAX3266's FIFO
......@@ -135,7 +135,7 @@ char setSEN15219OutputMode(void)
tx_buffer_i2c[2] = OUTPUT_MODE_SENSOR_ALGORITHM;
error_flag = i2cTransmit(&tx_buffer_i2c[0], 3);
waitMilliseconds(COMMAND_DELAY_SEN15219);
waitMilliseconds(ENABLE_DELAY_SEN15219);
error_flag = i2cReceive(&rx_buffer_i2c[0], 1);
......@@ -365,7 +365,10 @@ void decodeReceivedData(char* data, int received_packets)
value |= aux << 8;
aux = data[i*FIFO_RESPONSE_FORMAT_LENGTH + 14];
value |= aux;
if(value != 0)
{
heart_rate = value;
}
confidence_level = data[i*FIFO_RESPONSE_FORMAT_LENGTH + 15];
......@@ -374,11 +377,16 @@ void decodeReceivedData(char* data, int received_packets)
value |= aux << 8;
aux = data[i*FIFO_RESPONSE_FORMAT_LENGTH + 17];
value |= aux;
if(value != 0)
{
oxygen_saturation = value;
}
}
else
{
finger_detected_counter = 0;
heart_rate = 0;
oxygen_saturation = 0;
}
}
}
......@@ -397,7 +405,65 @@ char getLedsRawData(int* led_ir, int* led_red)
return data_available;
}
int getConfidenceLevel(void)
{
return confidence_level;
}
int getHeartRate(void)
{
return heart_rate;
}
int getOxygenSaturation(void)
{
return oxygen_saturation;
}
//TODO Remove - used for troubleshooting
void testQueue(void)
{
if(!intQueueIsFull(head_ir, tail_ir, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(1, &head_ir, ir_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_red, tail_red, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(1, &head_red, red_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_ir, tail_ir, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(2, &head_ir, ir_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_red, tail_red, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(2, &head_red, red_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_ir, tail_ir, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(3, &head_ir, ir_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_red, tail_red, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(3, &head_red, red_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_ir, tail_ir, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(4, &head_ir, ir_queue, BIOMETRIC_QUEUE_DIMENSION);
}
if(!intQueueIsFull(head_red, tail_red, BIOMETRIC_QUEUE_DIMENSION))
{
addToIntQueue(4, &head_red, red_queue, BIOMETRIC_QUEUE_DIMENSION);
}
}
void cleanRXBuffer(void)
{
int i;
......
......@@ -15,7 +15,7 @@ void fastPeriodicFunction(void);
volatile int prueba_slow;
volatile int prueba_fast;
volatile int fast_counter;
volatile int fast_counter, slow_counter;
static int bluetoothTransmissionEnable = 0;
static int bluetoothTransmissionMode = 0;
......@@ -26,8 +26,6 @@ void initializeTimingLogic(void)
configureTimer();
setSlowFunctionISRCallbackFunction(slowPeriodicFunction);
setFastFunctionISRCallbackFunction(fastPeriodicFunction);
fast_counter = 0;
}
unsigned int getAuxiliaryMilisecondsTime(void)
......@@ -104,7 +102,14 @@ void slowPeriodicFunction(void)
if(bluetoothTransmissionEnable)
{
sendRawValues();
if(slow_counter == 5)
{
sendProcessedValues();
runADCConversion();
slow_counter = 0;
}
slow_counter++;
}
}
......@@ -126,6 +131,7 @@ void fastPeriodicFunction(void)
if(fast_counter == 1)
{
readSamples();
//testQueue();
fast_counter = 0;
}
fast_counter++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment