mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-18 19:50:17 +02:00
labsw/sw/: basic firmware - just enumerates
This commit is contained in:
parent
14f70fd819
commit
e73383b7d8
35
labsw/fw/Makefile
Normal file
35
labsw/fw/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# labsw/Makefile - Makefile for the Lab Switch firmware
|
||||
#
|
||||
# Written 2011 by Werner Almesberger
|
||||
# Copyright 2011 Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
|
||||
MAIN = labsw
|
||||
OBJS = $(MAIN) usb descr # version ep0
|
||||
|
||||
F32XBASE = ../../../f32xbase
|
||||
|
||||
include $(F32XBASE)/fw/common/Makefile.system
|
||||
include $(F32XBASE)/fw/common/Makefile.common
|
||||
|
||||
CFLAGS += -I../common -I../include
|
||||
LDFLAGS += --code-size $(PAYLOAD_SIZE) --code-loc $(PAYLOAD_START)
|
||||
|
||||
USB_ID = $(shell \
|
||||
( echo '\#include "usb-id.h"'; echo USB_VENDOR:USB_PRODUCT; ) | \
|
||||
cpp | sed '/^ *$$/d;/^\#/d' )
|
||||
|
||||
.PHONY: dfu
|
||||
|
||||
# hack: for now, we just reuse the boot loader from cntr
|
||||
USB_ID = 20b7:cb72
|
||||
|
||||
dfu:
|
||||
dfu-util -d $(USB_ID) -D $(MAIN).bin
|
1
labsw/fw/config.h
Normal file
1
labsw/fw/config.h
Normal file
@ -0,0 +1 @@
|
||||
#include "usb-id.h"
|
68
labsw/fw/descr.c
Normal file
68
labsw/fw/descr.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* descr.c - USB descriptors
|
||||
*
|
||||
* Written 2008-2011 by Werner Almesberger
|
||||
* Copyright 2008-2011 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/*
|
||||
* Device descriptor
|
||||
*/
|
||||
|
||||
const uint8_t device_descriptor[18] = {
|
||||
18, /* bLength */
|
||||
USB_DT_DEVICE, /* bDescriptorType */
|
||||
LE(0x200), /* bcdUSB */
|
||||
USB_CLASS_VENDOR_SPEC, /* bDeviceClass */
|
||||
0x00, /* bDeviceSubClass */
|
||||
0x00, /* bDeviceProtocol */
|
||||
EP0_SIZE, /* bMaxPacketSize */
|
||||
LE(USB_VENDOR), /* idVendor */
|
||||
LE(USB_PRODUCT), /* idProduct */
|
||||
LE(0x0001), /* bcdDevice */
|
||||
0, /* iManufacturer */
|
||||
0, /* iProduct */
|
||||
0, /* iSerialNumber */
|
||||
1 /* bNumConfigurations */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Our configuration
|
||||
*
|
||||
* We're always bus-powered.
|
||||
*/
|
||||
|
||||
const uint8_t config_descriptor[] = {
|
||||
9, /* bLength */
|
||||
USB_DT_CONFIG, /* bDescriptorType */
|
||||
LE(9+9), /* wTotalLength */
|
||||
1, /* bNumInterfaces */
|
||||
1, /* bConfigurationValue (> 0 !) */
|
||||
0, /* iConfiguration */
|
||||
USB_ATTR_BUS_POWERED, /* bmAttributes */
|
||||
15, /* bMaxPower */
|
||||
|
||||
/* Interface #0 */
|
||||
|
||||
9, /* bLength */
|
||||
USB_DT_INTERFACE, /* bDescriptorType */
|
||||
0, /* bInterfaceNumber */
|
||||
0, /* bAlternateSetting */
|
||||
0, /* bNumEndpoints */
|
||||
USB_CLASS_VENDOR_SPEC, /* bInterfaceClass */
|
||||
0, /* bInterfaceSubClass */
|
||||
0, /* bInterfaceProtocol */
|
||||
0, /* iInterface */
|
||||
};
|
35
labsw/fw/labsw.c
Normal file
35
labsw/fw/labsw.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* labsw.c - Lab Switch initialization and main loop
|
||||
*
|
||||
* Written 2011 by Werner Almesberger
|
||||
* Copyright 2011 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "regs.h"
|
||||
#include "usb.h"
|
||||
|
||||
|
||||
static void init_io(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
init_io();
|
||||
|
||||
usb_init();
|
||||
// ep0_init();
|
||||
|
||||
while (1) {
|
||||
usb_poll();
|
||||
}
|
||||
}
|
1
labsw/fw/regs.h
Normal file
1
labsw/fw/regs.h
Normal file
@ -0,0 +1 @@
|
||||
#include "regs-f320.h"
|
29
labsw/fw/usb-id.h
Normal file
29
labsw/fw/usb-id.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* labsw/usb-id.h - USB vendor and product ID
|
||||
*
|
||||
* Written 2011 by Werner Almesberger
|
||||
* Copyright 2011 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef USB_ID_H
|
||||
#define USB_ID_H
|
||||
|
||||
/*
|
||||
* Platform-specific settings
|
||||
*
|
||||
* USB_VENDOR = Qi Hardware
|
||||
* USB_PRODUCT = 7ab5
|
||||
*
|
||||
* 7ab5 is "LABS" in "leet", http://en.wikipedia.org/wiki/Leet
|
||||
*/
|
||||
|
||||
#define USB_VENDOR 0x20b7 /* Qi Hardware */
|
||||
#define USB_PRODUCT 0x7ab5 /* Lab Switch */
|
||||
|
||||
#endif /* !USB_ID_H */
|
Loading…
Reference in New Issue
Block a user