firmware WIP

This commit is contained in:
Pavol Rusnak 2011-04-04 21:28:41 +02:00
parent e78c314556
commit b46d41bd34
43 changed files with 1059 additions and 5161 deletions

View file

@ -0,0 +1,99 @@
/*----------------------------------------------------------------------------
* Name: DEMO.C
* Purpose: USB HID Demo
* Version: V1.20
*----------------------------------------------------------------------------
* This software is supplied "AS IS" without any warranties, express,
* implied or statutory, including but not limited to the implied
* warranties of fitness for purpose, satisfactory quality and
* noninfringement. Keil extends you a royalty-free right to reproduce
* and distribute executable files created using this software for use
* on NXP Semiconductors LPC microcontroller devices only. Nothing else
* gives you the right to use this software.
*
* Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#include "LPC13xx.h" /* LPC13xx definitions */
#include "usb.h"
#include "usbdesc.h"
#include "gpio.h"
#include "rom_drivers.h"
#include "config.h"
#define EN_TIMER32_1 (1<<10)
#define EN_IOCON (1<<16)
#define EN_USBREG (1<<14)
USB_DEV_INFO DeviceInfo;
HID_DEVICE_INFO HidDevInfo;
ROM ** rom = (ROM **)0x1fff1ff8;
/*
* Get HID Input Report -> InReport
*/
volatile uint8_t buffer[8];
void GetInReport (uint8_t src[], uint32_t length)
{
src[0] = buffer[0];
}
/*
* Set HID Output Report <- OutReport
*/
void SetOutReport (uint8_t dst[], uint32_t length)
{
buffer[0] = dst[0];
}
int main (void)
{
/* for delay loop */
volatile int n;
// Code Red Red Suite and LPCXpresso by Code Red both call SystemInit() in
// the C startup code
#ifndef __CODERED__
SystemInit();
#endif
HidDevInfo.idVendor = USB_VENDOR_ID;
HidDevInfo.idProduct = USB_PROD_ID;
HidDevInfo.bcdDevice = USB_DEVICE;
HidDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0];
HidDevInfo.InReportCount = 1;
HidDevInfo.OutReportCount = 1;
HidDevInfo.SampleInterval = 0x20;
HidDevInfo.InReport = GetInReport;
HidDevInfo.OutReport = SetOutReport;
DeviceInfo.DevType = USB_DEVICE_CLASS_HUMAN_INTERFACE;
DeviceInfo.DevDetailPtr = (uint32_t)&HidDevInfo;
/* Enable Timer32_1, IOCON, and USB blocks (for USB ROM driver) */
LPC_SYSCON->SYSAHBCLKCTRL |= (EN_TIMER32_1 | EN_IOCON | EN_USBREG);
/* Use pll and pin init function in rom */
(*rom)->pUSBD->init_clk_pins();
/* insert a delay between clk init and usb init */
for (n = 0; n < 75; n++) {}
(*rom)->pUSBD->init(&DeviceInfo); /* USB Initialization */
(*rom)->pUSBD->connect(TRUE); /* USB Connect */
while (1)
__WFI();
}
#if defined(__IAR__)
void USBIRQ_IRQHandler()
#else
void USB_IRQHandler()
#endif
{
(*rom)->pUSBD->isr();
}