Files
@ b23f284b2449
Branch filter:
Location: seniordesign-firmware/slave/slave/slave.c
b23f284b2449
2.8 KiB
text/plain
Lots of work on module identification, sensor integration, and debug serial output formatting. Extra setup work was done porting code to new micros.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | /*
* Slave Firmware
*
* Wireless Observational Modular Aerial Network
*
* Kyle Ripperger
* Ethan Zonca
* Matthew Kanning
* Matthew Kroening
*
*/
#include "config.h"
#include <inttypes.h>
#include <avr/io.h>
#include <compat/twi.h>
#include <util/delay.h>
#include <avr/cpufunc.h>
#include <avr/interrupt.h>
#include "modules.h"
#include "lib/serial.h"
#include "lib/led.h"
#include "lib/inputOutput.h"
#include "lib/i2c.h"
#include "lib/spi.h"
#include "lib/geiger.h"
#include "lib/sensors.h"
#include "lib/cameras.h"
void micro_setup()
{
// Generic microcontroller config options
sei(); // Enable interrupts
}
int main(void)
{
// Initialize
micro_setup(); // Generic microcontroller config options
led_configure(); // Configure ports and registers for LED operation
io_configure(); // Configure IO ports and registers
i2c_init(); // Setup I2C
serial0_setup(); // Config serial port
uint8_t moduleID = io_getModuleId(); // Slave Module ID from rotary dip switch
modules_setup(moduleID); // Run setup functions for specific module
uint8_t test; //Debug
uint8_t test2; //Debug
//PORTA &= ~(1 << PA1); //DEBUG////////////////OFF///////////////////////////////////////////////////////////////
//PORTA |= (1 << PA1); //DEBUG///////////////ON////////////////////////////////////////////////////////////////
// This is just a serial output example
char buff[32]; //DEBUG///////////////////////////////////////////////////////////////////////////////////////
serial0_sendString("Starting\r\n");
while(1)
{
modules_run(moduleID); // Runs specific module functions (like data reading)
// Use program timer to run every so often. Time interval defined in config.h (TODO)
// This is just a serial output example
//sprintf(buff, "log: %u,%u,%u,%u\r\n", temp,temp2,temp3,temp4);
//i2c_write(RTC_ADDR, 0x05, 0x3A); //DEBUG: EXAMPLE//////////////////////////////////////////////////////
_delay_ms(10); //DEBUG/////////////
test = geiger_getCount(); //Debug//////////
led_output(test);//DEBUG//////////
/********Examples of data reading and getting******************
x = geiger_getCpm(); //Data get
x = sensors_getSpiTemp(); //Data get
x = sensors_getBoardTemp(); //Data get
sensors_readSpiTemp(); //Data Read
sensors_readBoardTemp(); //Data Read
**************************************************************/
test2 = sensors_getBoardTemp(); //DEBUG///////////////////////////////////////////////////////////////////////////
sprintf(buff, "|ModuleID: %u |BoardTemp: %u |Seconds: %u\r\n",moduleID,test2,test); //DEBUG
serial0_sendString(buff); //DEBUG
}
return 0;
}
|