firmware/main.c File Reference

Firmware for the USB-LED-Fader. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "usbdrv.h"
#include "oddebug.h"
#include "pwm_channels.h"
#include "usbledfader.h"
#include "channels.h"

Go to the source code of this file.

Functions

void fade_startWaveform (uint8_t ledId, uint8_t waveId, uint8_t waveformId, uint8_t periodDuration, uint8_t repetitionCount)
 Start displaying a certain waveform on a single LED.
void fade_globalData_init (void)
 Fills fade_globalData.
uchar usbFunctionRead (uchar *data, uchar len)
 USB-Data-Handler (device -> host).
uchar usbFunctionWrite (uchar *data, uchar len)
 USB-Data-Handler (host -> device).
uchar usbFunctionSetup (uchar data[8])
 USB-Setup-Handler.
int main (void)
 Main-function.


Detailed Description

Firmware for the USB-LED-Fader.

Author:
Ronald Schaten & Thomas Stegemann
Version:
Id
main.c,v 1.2 2006/09/29 21:51:07 rschaten Exp
License: See documentation.

Definition in file main.c.


Function Documentation

void fade_globalData_init ( void   ) 

Fills fade_globalData.

The state of all LEDs is initialized to off. One signal is displayed on all LEDs to ensure they're working.

Definition at line 134 of file main.c.

References fade_calculateWaveform(), fade_startWaveform(), S_fade_GlobalData::led, S_fade_LedState::wave, S_fade_LedState::waveCurrentId, S_fade_LedState::waveCurrentPosition, S_fade_LedState::waveCurrentRepetition, S_fade_Waveform::waveformDuration, S_fade_Waveform::waveformId, S_fade_Waveform::waveformLength, S_fade_Waveform::waveformRepetition, S_fade_Waveform::waveformUpdateTime, and S_fade_LedState::waveNextUpdate.

Referenced by main(), and usbFunctionSetup().

void fade_startWaveform ( uint8_t  ledId,
uint8_t  waveId,
uint8_t  waveformId,
uint8_t  periodDuration,
uint8_t  repetitionCount 
)

Start displaying a certain waveform on a single LED.

Parameters:
ledId ID of the LED that is changed.
waveId ID of the wave that to be set: 0 and 1 are the base waves, 2 is the override wave.
waveformId ID of the Waveform that is to be assigned to the LED.
periodDuration How long should this wave stay on display? Time in seconds/10.
repetitionCount How many times should this wave be repeated while it is on display?

Definition at line 99 of file main.c.

References fade_calculateWaveform(), S_fade_GlobalData::led, S_fade_LedState::wave, S_fade_LedState::waveCurrentId, S_fade_LedState::waveCurrentPosition, S_fade_LedState::waveCurrentRepetition, S_fade_Waveform::waveformDuration, S_fade_Waveform::waveformId, S_fade_Waveform::waveformLength, S_fade_Waveform::waveformRepetition, S_fade_Waveform::waveformUpdateTime, and S_fade_LedState::waveNextUpdate.

Referenced by fade_globalData_init(), usbFunctionSetup(), and usbFunctionWrite().

int main ( void   ) 

Main-function.

Initializes the hardware and starts the main loop of the application.

Returns:
An integer. Whatever... :-)

Definition at line 247 of file main.c.

References fade_globalData_init(), and pwm_Channels_init().

uchar usbFunctionRead ( uchar *  data,
uchar  len 
)

USB-Data-Handler (device -> host).

Handles data that is to be sent to the host via USB-Interface. In our case the data contains the current settings for the LEDs. This function is called until the returned length is shorter than the buffer (typically 8 bytes).

Parameters:
data Buffer for the data.
len Length of the buffer.
Returns:
Length of the returned buffer.

Definition at line 166 of file main.c.

uchar usbFunctionSetup ( uchar  data[8]  ) 

USB-Setup-Handler.

Handles setup-calls that are received from the USB-Interface.

Parameters:
data Eight bytes of data.
Returns:
The number of returned bytes (in replyBuffer[]).

Definition at line 203 of file main.c.

References CMD_CLEAR, CMD_ECHO, CMD_GET, CMD_RESET, CMD_SET, fade_globalData_init(), fade_startWaveform(), msgErr, and msgOK.

uchar usbFunctionWrite ( uchar *  data,
uchar  len 
)

USB-Data-Handler (host -> device).

Handles data that is received from the USB-Interface. In our case the data contains settings for the LEDs.

Parameters:
data The received data, up to 8 bytes.
len Length of the received data.
Returns:
1 if we have received the entire payload successfully, 0 if we expect more data. We don't, so we always return 1.

Definition at line 184 of file main.c.

References fade_startWaveform().


Generated on Mon Oct 2 19:31:17 2006 for USB-LED-Fader by  doxygen 1.4.7