Defines | |
#define | BASE 31250/2 |
Play polyphonic tune using buzzer. | |
#define | MEASURE_ADC2 1 |
Initialize the temperature sensor ADC2=EXT_SUPL_SIG can also be measured and sent to the 1284p along with the temperature reading. | |
Enumerations | |
enum | temp_zero_offset_t |
Type used together with find_temp() to find temperature. | |
enum | temp_unit_t |
Type used with temp_get() to select temperature unit. | |
Functions | |
int | adc_init (adc_chan_t chan, adc_trig_t trig, adc_ref_t ref, adc_ps_t prescale) |
This function will init the ADC with the following parameters. | |
void | adc_deinit (void) |
This will disable the adc. | |
int | adc_conversion_start (void) |
This will start an ADC conversion. | |
int16_t | adc_result_get (adc_adj_t adjust) |
This will read the ADC result during the ADC conversion and return the raw ADC conversion result. | |
void | key_init (void) |
This will intialize the joystick and the ADC for button readings. | |
void | key_deinit (void) |
This will disable the ADC used for button readings. | |
uint8_t | is_button (void) |
This will poll run key_task() to determine if a button has been pressed. | |
uint8_t | get_button (void) |
This function will wait for a user to press a button. | |
key_state_t | key_task (void) |
This will check the joystick state to return the current button status. | |
key_state_t | key_state_get (void) |
This function will start the ADC conversion and read the current converstion value to determine the button position. | |
int | lcd_init (void) |
This function will initialize the proper settings for the LCD driver. | |
void | lcd_deinit (void) |
This will disable the LCD operation. | |
uint8_t | itobcd (uint8_t inNumber) |
This will convert the incoming decimal number to BCD. | |
int | lcd_num_puthex (uint16_t numb, lcd_padding_t padding) |
This will put a HEX value on the LCD that represents the input parameter. | |
int | lcd_num_putdec (int numb, lcd_padding_t padding) |
This will put a DEC value on the LCD that represents the input parameter. | |
int | lcd_num_clr (void) |
This will clear numbers displayed on the LCD. | |
int | lcd_puts (const char *s) |
This will put a string of characters out to the LCD. | |
int | lcd_puta (size_t length, const uint8_t *s) |
This will put a string of characters of a certain length out to the LCD. | |
int | lcd_puts_P (const char *s) |
This will put a string out to the LCD from Flash. | |
int | lcd_putchar (unsigned char c) |
This will put a single character out to the LCD. | |
void | lcd_symbol_set (lcd_symbol_t symbol) |
This will enable any of the symbols on the Raven LCD. | |
void | lcd_symbol_clr (lcd_symbol_t symbol) |
This will clear any symbol on the Raven LCD. | |
void | lcd_symbol_set_group (int start, int count) |
This will enable a group of symbols from the lcd_symbol_chart. | |
void | lcd_symbol_clr_group (int start, int count) |
This will disable a group of symbols from the lcd_symbol_chart. | |
ISR (LCD_vect) | |
This is the LCD Start of Frame Interrupt Subroutine. | |
void | led_on (void) |
Turns the Raven nose LED on. | |
void | led_off (void) |
Turns the Raven nose LED off. | |
void | lcd_single_print_dig (uint8_t numb, uint8_t pos) |
This will add the passed in number to any of the four locations of the four digit segment display on the LCD. | |
void | dectoascii (uint8_t val, char *str) |
This function will convert decimal to ascii. | |
uint8_t * | signed_dectoascii (int16_t n, uint8_t *str) |
This will convert a signed decimal number to ASCII. | |
void | eeprom_init (void) |
This will check for DEBUG mode after power up. | |
void | menu_run_sleep (uint8_t *val) |
This will start a sleep operation. | |
void | menu_run_doze (uint8_t *val) |
This will start a sleep with wakes for temperature measurement and web requests. | |
void | menu_ping_request (uint8_t *val) |
This will setup a ping request command to the 1284p and reset the ping counter. | |
uint8_t | menu_send_ping (void) |
This will send the ping request to the 1284p via the serial port. | |
void | menu_stop_ping (void) |
This will stop the ping request. | |
void | menu_debug_mode (uint8_t *val) |
This will enable or disable the JTAG debug interface to allow for proper temperature sensor readings. | |
void | menu_read_temp (uint8_t *val) |
This will display the temperature in degrees F or C. | |
void | menu_display_temp (void) |
This will display the temperature in degrees F or C. | |
void | menu_clear_temp (void) |
This will clear the temperature displayed in the 4 digit LCD segments. | |
void | menu_prepare_temp (uint8_t *val) |
This will setup the current temperature for transfer to the ATmega1284p via a binary command transfer. | |
void | menu_stop_temp (void) |
This will stop the auto sending of temperature data. | |
void | menu_send_temp (void) |
This will send the data via the serial port. | |
void | read_menu (uint8_t ndx) |
This will read the menu_items[] from the index requested. | |
void | check_main_menu (void) |
This will toggle the CONTIKI and 6LOWPAN LCD menus in the main menu position, unless alternate text has been sent from the 1284p. | |
void | check_menu (void) |
This will check for the temp menu screen to determine if we need to clear the 4 digit LCD segments or stop an auto temp send. | |
int | main (void) |
This is main. | |
void | sleep_now (int howlong) |
Prepares for and executes sleep. | |
void | sleep_wakeup (void) |
This will send a wakeup command to ATmega1284p It may already be awake, if not it will respond during the next wake cycle Upon receiving the command it will return an acknowledgement frame. | |
ISR (PCINT0_vect) | |
This is the wake up button interrupt. | |
ISR (TIMER2_OVF_vect) | |
This is the timer2 overflow interrupt. | |
int | temp_init (void) |
This will initialize the digital IO and adc channel for temperture readings. | |
void | temp_deinit (void) |
This will disable temperature readings by reseting the initialed flag. | |
int16_t | temp_get (temp_unit_t unit) |
This will turn on the adc channel for reading the temp sensor. | |
void | timer_init (void) |
TIMER1 init for timer used by LCD. | |
void | timer_start (void) |
Start the timer. | |
void | timer_stop (void) |
Stop the timer. | |
ISR (TIMER1_COMPA_vect) | |
This is the interrupt subroutine for the TIMER1 output match comparison. | |
void | uart_init_circ_buf (tcirc_buf *cbuf) |
This will intialize the circular buffer head and tail of tcirc_buf struct. | |
void | uart_add_to_circ_buf (tcirc_buf *cbuf, uint8_t ch) |
This will add a new character to the circular buffer. | |
uint8_t | uart_get_from_circ_buf (tcirc_buf *cbuf) |
This will get a character from the buffer requested. | |
void | uart_clear_rx_buf (void) |
This will clear the RX buffer. | |
uint8_t | uart_circ_buf_has_char (tcirc_buf *cbuf) |
This will check for a character in the requested buffer. | |
uint8_t | uip_ntohex (uint8_t val) |
This will convert a nibble to a hex value. | |
void | itohex (uint8_t val, char *str) |
Convert integer to hex value. | |
uint8_t | uart_get_char_rx (void) |
This will wait for a new character from the ATmega1284p and timeout if no new character is received. | |
void | uart_init (void) |
Initialize UART to 38400 Baud Rate and only enable UART for transmission. | |
void | uart_deinit (void) |
Turn off UART for sleep mode. | |
void | uart_send_byte (uint8_t byte) |
Send one byte over the uart. | |
ISR (USART_RX_vect) | |
This is the USART RX complete interrupt. | |
void | uart_serial_send_frame (uint8_t cmd, uint8_t payload_length, uint8_t *payload) |
This function builds and sends a binary command frame to the ATmega1284p. | |
void | uart_timeout_msg (uint8_t x) |
This displays a time out message to the user based on the parameter reason x. | |
void | uart_serial_rcv_frame (uint8_t wait_for_ack) |
This will receive a frame from the ATmega1284p and parse the incoming data. | |
Variables | |
bool | temp_initialized = false |
Flag indicating initialized or not. | |
tcirc_buf | rxbuf |
The RX circular buffer, for storing characters from serial port. | |
Definition of Port Pin for temp sensor. | |
| |
#define | TEMP_PORT PORTF |
#define | TEMP_DDR DDRF |
#define | TEMP_PIN PINF |
#define | TEMP_BIT_IN 4 |
#define | TEMP_BIT_PWR 6 |
#define BASE 31250/2 |
#define MEASURE_ADC2 1 |
int adc_conversion_start | ( | void | ) |
This will start an ADC conversion.
Definition at line 105 of file adc.c.
Referenced by key_state_get().
int adc_init | ( | adc_chan_t | chan, | |
adc_trig_t | trig, | |||
adc_ref_t | ref, | |||
adc_ps_t | prescale | |||
) |
This function will init the ADC with the following parameters.
chan | Determines the ADC channel to open. | |
trig | Sets what type of trigger is needed. | |
ref | Sets the proper reference voltage. | |
prescale | Sets the prescale to be used against the XTAL choice. |
int16_t adc_result_get | ( | adc_adj_t | adjust | ) |
This will read the ADC result during the ADC conversion and return the raw ADC conversion result.
adjust | This will Left or Right Adjust the ADC conversion result. |
Definition at line 126 of file adc.c.
Referenced by key_state_get().
void check_main_menu | ( | void | ) |
This will toggle the CONTIKI and 6LOWPAN LCD menus in the main menu position, unless alternate text has been sent from the 1284p.
The other menus will display normally.
Definition at line 278 of file raven3290.c.
References lcd_puts(), lcd_puts_P(), read_menu(), and tmenu_item::text.
Referenced by main().
void check_menu | ( | void | ) |
This will check for the temp menu screen to determine if we need to clear the 4 digit LCD segments or stop an auto temp send.
Also check for stopping a ping request.
Definition at line 307 of file raven3290.c.
References lcd_num_clr(), menu_clear_temp(), menu_stop_ping(), menu_stop_temp(), and tmenu_item::text.
Referenced by main().
void dectoascii | ( | uint8_t | val, | |
char * | str | |||
) |
This function will convert decimal to ascii.
val | Decimal value to convert. | |
str | Address location to store converted value. |
Definition at line 76 of file menu.c.
Referenced by uart_timeout_msg().
void eeprom_init | ( | void | ) |
This will check for DEBUG mode after power up.
Initialize the EEPROM module.
Definition at line 142 of file menu.c.
References menu_debug_mode().
Referenced by main().
uint8_t get_button | ( | void | ) |
This function will wait for a user to press a button.
Definition at line 114 of file key.c.
References is_button().
Referenced by main(), menu_run_doze(), and menu_run_sleep().
uint8_t is_button | ( | void | ) |
This will poll run key_task() to determine if a button has been pressed.
True | if button is pressed | |
False | if button is not pressed |
Definition at line 95 of file key.c.
References key_task().
Referenced by get_button(), main(), menu_run_doze(), and menu_run_sleep().
ISR | ( | TIMER2_OVF_vect | ) |
ISR | ( | PCINT0_vect | ) |
ISR | ( | LCD_vect | ) |
uint8_t itobcd | ( | uint8_t | inNumber | ) |
This will convert the incoming decimal number to BCD.
inNumber | Decimal number to convert |
Definition at line 356 of file lcd.c.
Referenced by lcd_num_putdec().
void itohex | ( | uint8_t | val, | |
char * | str | |||
) |
Convert integer to hex value.
val | Value to convert to hex. | |
str | Location to store converted value. |
Definition at line 179 of file uart.c.
References uip_ntohex().
key_state_t key_state_get | ( | void | ) |
This function will start the ADC conversion and read the current converstion value to determine the button position.
KEY_ENTER | Enter button has been pressed. | |
KEY_UP | Up Button has been pressed. | |
KEY_RIGHT | Right Button has been pressed. | |
KEY_LEFT | Left Button has been pressed. | |
KEY_DOWN | Down Button has been pressed. | |
KEY_NO_KEY | No Button has been pressed. |
Definition at line 174 of file key.c.
References adc_conversion_start(), adc_result_get(), and ENTER_PORT.
Referenced by key_task(), menu_run_doze(), and menu_run_sleep().
key_state_t key_task | ( | void | ) |
This will check the joystick state to return the current button status.
Definition at line 133 of file key.c.
References key_state_get().
Referenced by is_button().
int lcd_init | ( | void | ) |
This function will initialize the proper settings for the LCD driver.
Initialization and configuration of the LCD controller.
This ATmega3290p can directly support an LCD through register mapping.
Definition at line 277 of file lcd.c.
Referenced by main(), menu_run_doze(), and menu_run_sleep().
int lcd_num_clr | ( | void | ) |
This will clear numbers displayed on the LCD.
Definition at line 428 of file lcd.c.
Referenced by check_menu(), and menu_clear_temp().
int lcd_num_putdec | ( | int | numb, | |
lcd_padding_t | padding | |||
) |
This will put a DEC value on the LCD that represents the input parameter.
numb | Number to display as DEC. | |
padding | This pads the location to place the value on the LCD. |
Definition at line 402 of file lcd.c.
References abs(), and itobcd().
Referenced by menu_display_temp().
int lcd_num_puthex | ( | uint16_t | numb, | |
lcd_padding_t | padding | |||
) |
int lcd_puta | ( | size_t | length, | |
const uint8_t * | s | |||
) |
int lcd_putchar | ( | unsigned char | c | ) |
int lcd_puts | ( | const char * | s | ) |
This will put a string of characters out to the LCD.
s | First character pointer of string. |
Definition at line 451 of file lcd.c.
Referenced by check_main_menu(), and uart_timeout_msg().
int lcd_puts_P | ( | const char * | s | ) |
This will put a string out to the LCD from Flash.
s | First character pointer of the string located in Flash |
Definition at line 498 of file lcd.c.
Referenced by check_main_menu(), main(), and sleep_wakeup().
void lcd_single_print_dig | ( | uint8_t | numb, | |
uint8_t | pos | |||
) |
This will add the passed in number to any of the four locations of the four digit segment display on the LCD.
numb | Number to display. | |
pos | Position to display number. |
Definition at line 890 of file lcd.c.
Referenced by menu_ping_request(), and uart_serial_rcv_frame().
void lcd_symbol_clr | ( | lcd_symbol_t | symbol | ) |
This will clear any symbol on the Raven LCD.
symbol | Specific symbol to clear from the LCD. |
Definition at line 566 of file lcd.c.
Referenced by lcd_symbol_clr_group(), menu_clear_temp(), menu_display_temp(), and uart_serial_rcv_frame().
void lcd_symbol_clr_group | ( | int | start, | |
int | count | |||
) |
This will disable a group of symbols from the lcd_symbol_chart.
start | Position of table to start from. | |
count | Number of symbols to disable from start position. |
Definition at line 614 of file lcd.c.
References lcd_symbol_clr().
void lcd_symbol_set | ( | lcd_symbol_t | symbol | ) |
This will enable any of the symbols on the Raven LCD.
symbol | Specific symbol to enable on the LCD. |
Definition at line 541 of file lcd.c.
Referenced by lcd_symbol_set_group(), main(), menu_display_temp(), menu_run_doze(), menu_run_sleep(), and uart_serial_rcv_frame().
void lcd_symbol_set_group | ( | int | start, | |
int | count | |||
) |
This will enable a group of symbols from the lcd_symbol_chart.
start | Position of table to start from. | |
count | Number of symbols to enable from start position. |
Definition at line 593 of file lcd.c.
References lcd_symbol_set().
void led_on | ( | void | ) |
Turns the Raven nose LED on.
Definition at line 862 of file lcd.c.
Referenced by menu_send_temp(), and uart_serial_rcv_frame().
int main | ( | void | ) |
This is main.
..
Definition at line 329 of file raven3290.c.
References check_main_menu(), check_menu(), tmenu_item::down, eeprom_init(), tmenu_item::enter_func, get_button(), is_button(), key_init(), lcd_init(), lcd_puts_P(), lcd_symbol_set(), tmenu_item::left, menu_display_temp(), menu_send_ping(), menu_send_temp(), menu_stop_ping(), read_menu(), tmenu_item::right, tmenu_item::state, temp_init(), tmenu_item::text, timer_init(), timer_start(), uart_serial_rcv_frame(), and tmenu_item::up.
void menu_debug_mode | ( | uint8_t * | val | ) |
This will enable or disable the JTAG debug interface to allow for proper temperature sensor readings.
val | Flag to trigger the proper debug mode. |
Definition at line 323 of file menu.c.
References temp_init().
Referenced by eeprom_init().
void menu_ping_request | ( | uint8_t * | val | ) |
This will setup a ping request command to the 1284p and reset the ping counter.
val | place holder |
Definition at line 264 of file menu.c.
References lcd_single_print_dig(), and menu_send_ping().
void menu_prepare_temp | ( | uint8_t * | val | ) |
This will setup the current temperature for transfer to the ATmega1284p via a binary command transfer.
val | This is used to determine sending once or auto based on the timer. |
Definition at line 424 of file menu.c.
References menu_send_temp().
void menu_read_temp | ( | uint8_t * | val | ) |
This will display the temperature in degrees F or C.
val | Flag to trigger F or C temperature conversion. |
Definition at line 354 of file menu.c.
References menu_display_temp().
void menu_run_doze | ( | uint8_t * | val | ) |
This will start a sleep with wakes for temperature measurement and web requests.
val | Used for remembering the new menu to display after a wakeup. |
Definition at line 215 of file menu.c.
References ENTER_PORT, get_button(), is_button(), key_state_get(), lcd_deinit(), lcd_init(), lcd_symbol_set(), led_off(), menu_send_temp(), sleep_now(), sleep_wakeup(), and uart_serial_send_frame().
void menu_run_sleep | ( | uint8_t * | val | ) |
This will start a sleep operation.
val | Used for remembering the new menu to display after a wakeup. |
Definition at line 165 of file menu.c.
References get_button(), is_button(), key_deinit(), key_init(), key_state_get(), lcd_deinit(), lcd_init(), lcd_symbol_set(), led_off(), sleep_now(), sleep_wakeup(), uart_deinit(), and uart_serial_send_frame().
uint8_t menu_send_ping | ( | void | ) |
This will send the ping request to the 1284p via the serial port.
Definition at line 290 of file menu.c.
References uart_serial_send_frame().
Referenced by main(), and menu_ping_request().
void read_menu | ( | uint8_t | ndx | ) |
This will read the menu_items[] from the index requested.
ndx | Position index of menu_items[] lookup. |
Definition at line 258 of file raven3290.c.
Referenced by check_main_menu(), and main().
uint8_t* signed_dectoascii | ( | int16_t | n, | |
uint8_t * | str | |||
) |
This will convert a signed decimal number to ASCII.
n | Signed number | |
str | Pointer to store converted value. |
Definition at line 93 of file menu.c.
Referenced by menu_send_temp().
void sleep_now | ( | int | howlong | ) |
Prepares for and executes sleep.
This function sets up the processor to enter sleep mode, and to wake up when the joystick button (PE2/PCINT2) is pressed or after the specified interval.
howlong | Seconds to sleep, 0=until button pushed |
Definition at line 68 of file sleep.c.
References ENTER_PORT.
Referenced by menu_run_doze(), and menu_run_sleep().
void sleep_wakeup | ( | void | ) |
This will send a wakeup command to ATmega1284p It may already be awake, if not it will respond during the next wake cycle Upon receiving the command it will return an acknowledgement frame.
This will send a single character forever to the ATmega1284p to cause a wakeup. The 1284p polls the USART for new data during each sleep cycle. Upon receiving a character from the user LCD, it will wake up and send an acknowledgement frame.
Definition at line 122 of file sleep.c.
References lcd_puts_P(), uart_serial_rcv_frame(), and uart_serial_send_frame().
Referenced by menu_run_doze(), and menu_run_sleep().
void temp_deinit | ( | void | ) |
This will disable temperature readings by reseting the initialed flag.
De-initialize the temperature sensor.
int16_t temp_get | ( | temp_unit_t | unit | ) |
This will turn on the adc channel for reading the temp sensor.
Read current temperature.
After the raw adc value is stored, it will be used to lookup a degree conversion based on the tables for F or C. Optionally, EXT_SUPL_SIG is also read on channel 2 and stored in the global ADC2_reading for subsequent transfer to the 1284p web server.
unit | Used to determine what unit needs to be appended with the value. |
temp | The newly converted value in degrees F or C. |
[in] | unit | Selected temperature unit (temp_unit_t) |
Referenced by menu_display_temp(), and menu_send_temp().
int temp_init | ( | void | ) |
This will initialize the digital IO and adc channel for temperture readings.
Optionally enable adc channel 2 for measurement of EXT_SUPL_SIG.
0 | Place holder for returning status. |
Referenced by main(), and menu_debug_mode().
void timer_init | ( | void | ) |
void uart_add_to_circ_buf | ( | tcirc_buf * | cbuf, | |
uint8_t | ch | |||
) |
This will add a new character to the circular buffer.
cbuf | Pointer to buffer where character will be stored. | |
ch | Character to store into buffer. |
Definition at line 80 of file uart.c.
References tcirc_buf::buf, tcirc_buf::head, and tcirc_buf::tail.
Referenced by ISR().
uint8_t uart_circ_buf_has_char | ( | tcirc_buf * | cbuf | ) |
This will check for a character in the requested buffer.
cbuf | Pointer to buffer to check for any characters. |
Definition at line 143 of file uart.c.
References tcirc_buf::head, and tcirc_buf::tail.
uint8_t uart_get_char_rx | ( | void | ) |
This will wait for a new character from the ATmega1284p and timeout if no new character is received.
TIMEOUT | Returns if timeout has occured. |
Definition at line 195 of file uart.c.
References uart_get_from_circ_buf().
Referenced by uart_serial_rcv_frame().
uint8_t uart_get_from_circ_buf | ( | tcirc_buf * | cbuf | ) |
This will get a character from the buffer requested.
cbuf | Pointer to buffer to get character from. |
Definition at line 107 of file uart.c.
References tcirc_buf::buf, and tcirc_buf::tail.
Referenced by uart_get_char_rx().
void uart_init | ( | void | ) |
Initialize UART to 38400 Baud Rate and only enable UART for transmission.
Initialize the UART module.
Definition at line 219 of file uart.c.
References uart_clear_rx_buf().
void uart_init_circ_buf | ( | tcirc_buf * | cbuf | ) |
This will intialize the circular buffer head and tail of tcirc_buf struct.
cbuf | Pointer to buffer to initialize. |
Definition at line 66 of file uart.c.
References tcirc_buf::head, and tcirc_buf::tail.
void uart_send_byte | ( | uint8_t | byte | ) |
Send one byte over the uart.
This is called to send binary commands.
byte | The byte of data to send out the uart. |
Definition at line 258 of file uart.c.
Referenced by uart_serial_send_frame().
void uart_serial_rcv_frame | ( | uint8_t | wait_for_ack | ) |
This will receive a frame from the ATmega1284p and parse the incoming data.
If the incoming data is a binary command acknowledgement, then this will not parse any data. If the incoming data is test reports, the menu will store the data for end of test metrics.
wait_for_ack | Flag used to wait for acknowledgement when receving a serial frame. |
Definition at line 340 of file uart.c.
References beep(), EOF_CHAR, lcd_single_print_dig(), lcd_symbol_clr(), lcd_symbol_set(), led_off(), led_on(), REPORT_PING, SOF_CHAR, uart_get_char_rx(), and uart_timeout_msg().
Referenced by main(), and sleep_wakeup().
void uart_serial_send_frame | ( | uint8_t | cmd, | |
uint8_t | payload_length, | |||
uint8_t * | payload | |||
) |
This function builds and sends a binary command frame to the ATmega1284p.
cmd | Command to send. | |
payload_length | Length of data to be sent with command. | |
payload | Pointer to data to send. |
Definition at line 295 of file uart.c.
References EOF_CHAR, SOF_CHAR, and uart_send_byte().
Referenced by menu_run_doze(), menu_run_sleep(), menu_send_ping(), menu_send_temp(), and sleep_wakeup().
void uart_timeout_msg | ( | uint8_t | x | ) |
This displays a time out message to the user based on the parameter reason x.
x | Reason for USART time out. |
Definition at line 318 of file uart.c.
References dectoascii(), and lcd_puts().
Referenced by uart_serial_rcv_frame().
uint8_t uip_ntohex | ( | uint8_t | val | ) |
The RX circular buffer, for storing characters from serial port.
Definition at line 56 of file uart.c.
Referenced by serial_line_input_byte().