Now compiles without error or warnings.
This commit is contained in:
parent
db7b59584b
commit
e2a1293fec
4 changed files with 86 additions and 19 deletions
|
@ -18,7 +18,12 @@
|
||||||
|
|
||||||
#include "../firmware/globals.h" /* custom request numbers */
|
#include "../firmware/globals.h" /* custom request numbers */
|
||||||
|
|
||||||
//#include "ledcube.h"
|
// External functions to control the ledcube.
|
||||||
|
extern void lc_setFrame(unsigned long);
|
||||||
|
extern void lc_setMode(int);
|
||||||
|
extern void lc_saveFrame(unsigned long, int);
|
||||||
|
extern void lc_init(void);
|
||||||
|
extern void lc_close(void);
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
#include "../firmware/globals.h" /* custom request numbers */
|
#include "../firmware/globals.h" /* custom request numbers */
|
||||||
|
|
||||||
//#include "ledcube.h"
|
|
||||||
|
|
||||||
extern void lc_setFrame(unsigned long);
|
extern void lc_setFrame(unsigned long);
|
||||||
extern void lc_setMode(int);
|
extern void lc_setMode(int);
|
||||||
extern void lc_saveFrame(unsigned long, int);
|
extern void lc_saveFrame(unsigned long, int);
|
||||||
|
|
|
@ -1,29 +1,66 @@
|
||||||
|
/*
|
||||||
|
* CTHN.de MiniLEDCube
|
||||||
|
*
|
||||||
|
* By Kai Lauterbach (klaute at web dot de) 11/2011
|
||||||
|
*
|
||||||
|
* Based on http://mosfetkiller.de/?s=miniledcube
|
||||||
|
*
|
||||||
|
* License: General Public License (GPL v3)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "ledcube.h"
|
#include "ledcube.h"
|
||||||
|
|
||||||
void lc_setFrame(unsigned long frame)
|
/**
|
||||||
|
* \param frame The 32bit frame data. Bit 0-8 equals layer one; bit 9 - 17 euqals layer two; bit 18 - 26 equals layer three. the 5 MSB is the lifetime of the current frame in ISR calls (300Hz).
|
||||||
|
* \return NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
|
||||||
|
*/
|
||||||
|
int lc_setFrame(unsigned long frame)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (_lc_handle == NULL)
|
||||||
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
int low = frame & 0xffff;
|
int low = frame & 0xffff;
|
||||||
int high = (frame & 0xffff0000) >> 16;
|
int high = (frame & 0xffff0000) >> 16;
|
||||||
|
|
||||||
usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, low, 0, _lc_buffer, 0, 300);
|
int ret = usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, low, 0, _lc_buffer, 0, 300);
|
||||||
usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, high, 1, _lc_buffer, 0, 300);
|
ret += usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, high, 1, _lc_buffer, 0, 300);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lc_setMode(int mode)
|
/**
|
||||||
|
* \param mode The firmware mode. MODE_ANIMATION_STOP; MODE_ANIMATION_SINGLE; MODE_ANIMATION_LOOP
|
||||||
|
* \return NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
|
||||||
|
*/
|
||||||
|
int lc_setMode(int mode)
|
||||||
{
|
{
|
||||||
usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_MODE, mode, 0, _lc_buffer, 0, 300);
|
if (_lc_handle == NULL)
|
||||||
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
|
return usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_MODE, mode, 0, _lc_buffer, 0, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lc_saveFrame(unsigned long frame, int index)
|
/**
|
||||||
|
* \param frame The 32bit frame data. Bit 0-8 equals layer one; bit 9 - 17 euqals layer two; bit 18 - 26 equals layer three. the 5 MSB is the lifetime of the current frame in ISR calls (300Hz).
|
||||||
|
* \param index The position in the EEPROM (0 to 31) of the internal animation content.
|
||||||
|
* \return NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
|
||||||
|
*/
|
||||||
|
int lc_saveFrame(unsigned long frame, int index)
|
||||||
{
|
{
|
||||||
|
if (_lc_handle == NULL)
|
||||||
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
lc_setFrame(frame);
|
lc_setFrame(frame);
|
||||||
|
|
||||||
usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_EEPROM_STORE_FRAME, 0, index, _lc_buffer, 0, 300);
|
return usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_EEPROM_STORE_FRAME, 0, index, _lc_buffer, 0, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lc_init()
|
/**
|
||||||
|
* \return SUCCESSFULLY_CONNECTED or DEVICE_NOT_FOUND_ERROR.
|
||||||
|
*/
|
||||||
|
int lc_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
usb_init();
|
usb_init();
|
||||||
|
@ -35,14 +72,21 @@ void lc_init()
|
||||||
/* The following function is in opendevice.c: */
|
/* The following function is in opendevice.c: */
|
||||||
if( usbOpenDevice( &_lc_handle, _lc_vid, _lc_vendor, _lc_pid, _lc_product, NULL, NULL, NULL) != 0)
|
if( usbOpenDevice( &_lc_handle, _lc_vid, _lc_vendor, _lc_pid, _lc_product, NULL, NULL, NULL) != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "Could not find USB device \"%s\" with lc_vid=0x%x lc_pid=0x%x\n", _lc_product, _lc_vid, _lc_pid);
|
fprintf(stderr, "Could not find USB device \"%s\" with lc_vid=0x%x lc_pid=0x%x\n", _lc_product, _lc_vid, _lc_pid);
|
||||||
|
return DEVICE_NOT_FOUND_ERROR;
|
||||||
}
|
}
|
||||||
|
return SUCCESSFULLY_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lc_close()
|
/**
|
||||||
|
* \return NOT_CONNECTED_ERROR or return state of the usb_close function.
|
||||||
|
*/
|
||||||
|
int lc_close()
|
||||||
{
|
{
|
||||||
usb_close(_lc_handle);
|
if (_lc_handle == NULL)
|
||||||
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
|
return usb_close(_lc_handle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* CTHN.de MiniLEDCube
|
||||||
|
*
|
||||||
|
* By Kai Lauterbach (klaute at web dot de) 11/2011
|
||||||
|
*
|
||||||
|
* Based on http://mosfetkiller.de/?s=miniledcube
|
||||||
|
*
|
||||||
|
* License: General Public License (GPL v3)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LEDCUBE_H_INCLUDED__
|
||||||
|
#define __LEDCUBE_H_INCLUDED__
|
||||||
|
|
||||||
|
#define NOT_CONNECTED_ERROR -1
|
||||||
|
#define DEVICE_NOT_FOUND_ERROR -2
|
||||||
|
|
||||||
|
#define SUCCESSFULLY_CONNECTED 1
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <usb.h> /* this is libusb */
|
#include <usb.h> /* this is libusb */
|
||||||
|
@ -21,9 +39,11 @@ char _lc_buffer[4];
|
||||||
int _lc_vid,
|
int _lc_vid,
|
||||||
_lc_pid;
|
_lc_pid;
|
||||||
|
|
||||||
void lc_setFrame(unsigned long);
|
int lc_setFrame(unsigned long);
|
||||||
void lc_setMode(int);
|
int lc_setMode(int);
|
||||||
void lc_saveFrame(unsigned long, int);
|
int lc_saveFrame(unsigned long, int);
|
||||||
void lc_init(void);
|
int lc_init(void);
|
||||||
void lc_close(void);
|
int lc_close(void);
|
||||||
|
|
||||||
|
#endif // __LEDCUBE_H_INCLUDED__
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue