Contiki 2.5
|
Macros | |
#define | BASE 31250/2 |
Play polyphonic tune using buzzer. More... | |
#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. More... | |
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. More... | |
int | adc_conversion_start (void) |
This will start an ADC conversion. More... | |
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. More... | |
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. More... | |
uint8_t | get_button (void) |
This function will wait for a user to press a button. More... | |
key_state_t | key_task (void) |
This will check the joystick state to return the current button status. More... | |
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. More... | |
int | lcd_init (void) |
This function will initialize the proper settings for the LCD driver. More... | |
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. More... | |
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. More... | |
int | lcd_num_putdec (int numb, lcd_padding_t padding) |
This will put a DEC value on the LCD that represents the input parameter. More... | |
int | lcd_num_clr (void) |
This will clear numbers displayed on the LCD. More... | |
int | lcd_puts (const char *s) |
This will put a string of characters out to the LCD. More... | |
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. More... | |
int | lcd_puts_P (const char *s) |
This will put a string out to the LCD from Flash. More... | |
int | lcd_putchar (unsigned char c) |
This will put a single character out to the LCD. More... | |
void | lcd_symbol_set (lcd_symbol_t symbol) |
This will enable any of the symbols on the Raven LCD. More... | |
void | lcd_symbol_clr (lcd_symbol_t symbol) |
This will clear any symbol on the Raven LCD. More... | |
void | lcd_symbol_set_group (int start, int count) |
This will enable a group of symbols from the lcd_symbol_chart. More... | |
void | lcd_symbol_clr_group (int start, int count) |
This will disable a group of symbols from the lcd_symbol_chart. More... | |
ISR (LCD_vect) | |
This is the LCD Start of Frame Interrupt Subroutine. More... | |
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. More... | |
void | dectoascii (uint8_t val, char *str) |
This function will convert decimal to ascii. More... | |
uint8_t * | signed_dectoascii (int16_t n, uint8_t *str) |
This will convert a signed decimal number to ASCII. More... | |
void | eeprom_init (void) |
This will check for DEBUG mode after power up. More... | |
void | menu_run_sleep (uint8_t *val) |
This will start a sleep operation. More... | |
void | menu_run_doze (uint8_t *val) |
This will start a sleep with wakes for temperature measurement and web requests. More... | |
void | menu_ping_request (uint8_t *val) |
This will setup a ping request command to the 1284p and reset the ping counter. More... | |
uint8_t | menu_send_ping (void) |
This will send the ping request to the 1284p via the serial port. More... | |
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. More... | |
void | menu_read_temp (uint8_t *val) |
This will display the temperature in degrees F or C. More... | |
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. More... | |
void | menu_stop_temp (void) |
This will stop the auto sending of temperature data. | |
void | read_menu (uint8_t ndx) |
This will read the menu_items[] from the index requested. More... | |
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. More... | |
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. More... | |
int | main (void) |
This is main... | |
void | sleep_now (int howlong) |
Prepares for and executes sleep. More... | |
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. More... | |
ISR (PCINT0_vect) | |
This is the wake up button interrupt. More... | |
ISR (TIMER2_OVF_vect) | |
This is the timer2 overflow interrupt. More... | |
int | temp_init (void) |
This will initialize the digital IO and adc channel for temperture readings. More... | |
void | temp_deinit (void) |
This will disable temperature readings by reseting the initialed flag. More... | |
int16_t | temp_get (temp_unit_t unit) |
Read current temperature. More... | |
void | timer_init (void) |
TIMER1 init for timer used by LCD. More... | |
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. More... | |
void | uart_add_to_circ_buf (tcirc_buf *cbuf, uint8_t ch) |
This will add a new character to the circular buffer. More... | |
uint8_t | uart_get_from_circ_buf (tcirc_buf *cbuf) |
This will get a character from the buffer requested. More... | |
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. More... | |
uint8_t | uip_ntohex (uint8_t val) |
This will convert a nibble to a hex value. More... | |
void | itohex (uint8_t val, char *str) |
Convert integer to hex value. More... | |
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. More... | |
void | uart_init (void) |
Initialize UART to 38400 Baud Rate and only enable UART for transmission. More... | |
void | uart_deinit (void) |
Turn off UART for sleep mode. | |
void | uart_send_byte (uint8_t byte) |
Send one byte over the uart. More... | |
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. More... | |
void | uart_timeout_msg (uint8_t x) |
This displays a time out message to the user based on the parameter reason x. More... | |
void | uart_serial_rcv_frame (uint8_t wait_for_ack) |
This will receive a frame from the ATmega1284p and parse the incoming data. More... | |
Variables | |
uint16_t | ADC2_reading |
This will send the data via the serial port. More... | |
bool | temp_initialized = false |
Flag indicating initialized or not. | |
uint16_t | ADC2_reading |
This will turn on the adc channel for reading the temp sensor. More... | |
tcirc_buf | rxbuf |
The RX circular buffer, for storing characters from serial port. More... | |
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(), and temp_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(), and temp_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 | ( | PCINT0_vect | ) |
ISR | ( | TIMER2_OVF_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(), and adc_result_get().
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 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 | ) |
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 get_button(), is_button(), key_state_get(), lcd_deinit(), lcd_init(), lcd_symbol_set(), led_off(), 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 | ||
) |
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.
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.
Definition at line 145 of file temp.c.
References temp_initialized.
int16_t temp_get | ( | temp_unit_t | unit | ) |
Read current temperature.
[in] | unit | Selected temperature unit (temp_unit_t) |
Definition at line 170 of file temp.c.
References ADC2_reading, adc_conversion_start(), adc_deinit(), ADC_REF_AVCC, adc_result_get(), key_init(), and temp_initialized.
Referenced by menu_display_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. |
Definition at line 113 of file temp.c.
References temp_initialized.
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(), 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(), 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 | ) |
uint16_t ADC2_reading |
This will turn on the adc channel for reading the temp sensor.
This will send the data via the serial port.
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. |
Definition at line 166 of file temp.c.
Referenced by temp_get().
uint16_t ADC2_reading |
This will send the data via the serial port.
This will send the data via the serial port.
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. |
Definition at line 166 of file temp.c.
Referenced by temp_get().
tcirc_buf rxbuf |
The RX circular buffer, for storing characters from serial port.
Definition at line 56 of file uart.c.
Referenced by serial_line_input_byte().