Date:2011-09-03 11:14:29 (12 years 6 months ago)
Author:Werner Almesberger
Commit:e73383b7d85ba231e10eb29e4d6407258c325cff
Message:labsw/sw/: basic firmware - just enumerates

Files: labsw/fw/Makefile (1 diff)
labsw/fw/config.h (1 diff)
labsw/fw/descr.c (1 diff)
labsw/fw/labsw.c (1 diff)
labsw/fw/regs.h (1 diff)
labsw/fw/usb-id.h (1 diff)

Change Details

labsw/fw/Makefile
1#
2# labsw/Makefile - Makefile for the Lab Switch firmware
3#
4# Written 2011 by Werner Almesberger
5# Copyright 2011 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14MAIN = labsw
15OBJS = $(MAIN) usb descr # version ep0
16
17F32XBASE = ../../../f32xbase
18
19include $(F32XBASE)/fw/common/Makefile.system
20include $(F32XBASE)/fw/common/Makefile.common
21
22CFLAGS += -I../common -I../include
23LDFLAGS += --code-size $(PAYLOAD_SIZE) --code-loc $(PAYLOAD_START)
24
25USB_ID = $(shell \
26  ( echo '\#include "usb-id.h"'; echo USB_VENDOR:USB_PRODUCT; ) | \
27  cpp | sed '/^ *$$/d;/^\#/d' )
28
29.PHONY: dfu
30
31# hack: for now, we just reuse the boot loader from cntr
32USB_ID = 20b7:cb72
33
34dfu:
35        dfu-util -d $(USB_ID) -D $(MAIN).bin
labsw/fw/config.h
1#include "usb-id.h"
labsw/fw/descr.c
1/*
2 * descr.c - USB descriptors
3 *
4 * Written 2008-2011 by Werner Almesberger
5 * Copyright 2008-2011 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include "usb.h"
15
16#include "config.h"
17
18
19/*
20 * Device descriptor
21 */
22
23const uint8_t device_descriptor[18] = {
24    18, /* bLength */
25    USB_DT_DEVICE, /* bDescriptorType */
26    LE(0x200), /* bcdUSB */
27    USB_CLASS_VENDOR_SPEC, /* bDeviceClass */
28    0x00, /* bDeviceSubClass */
29    0x00, /* bDeviceProtocol */
30    EP0_SIZE, /* bMaxPacketSize */
31    LE(USB_VENDOR), /* idVendor */
32    LE(USB_PRODUCT), /* idProduct */
33    LE(0x0001), /* bcdDevice */
34    0, /* iManufacturer */
35    0, /* iProduct */
36    0, /* iSerialNumber */
37    1 /* bNumConfigurations */
38};
39
40
41/*
42 * Our configuration
43 *
44 * We're always bus-powered.
45 */
46
47const uint8_t config_descriptor[] = {
48    9, /* bLength */
49    USB_DT_CONFIG, /* bDescriptorType */
50    LE(9+9), /* wTotalLength */
51    1, /* bNumInterfaces */
52    1, /* bConfigurationValue (> 0 !) */
53    0, /* iConfiguration */
54    USB_ATTR_BUS_POWERED, /* bmAttributes */
55    15, /* bMaxPower */
56
57    /* Interface #0 */
58
59    9, /* bLength */
60    USB_DT_INTERFACE, /* bDescriptorType */
61    0, /* bInterfaceNumber */
62    0, /* bAlternateSetting */
63    0, /* bNumEndpoints */
64    USB_CLASS_VENDOR_SPEC, /* bInterfaceClass */
65    0, /* bInterfaceSubClass */
66    0, /* bInterfaceProtocol */
67    0, /* iInterface */
68};
labsw/fw/labsw.c
1/*
2 * labsw.c - Lab Switch initialization and main loop
3 *
4 * Written 2011 by Werner Almesberger
5 * Copyright 2011 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include <stdint.h>
15
16#include "regs.h"
17#include "usb.h"
18
19
20static void init_io(void)
21{
22}
23
24
25void main(void)
26{
27    init_io();
28
29    usb_init();
30// ep0_init();
31
32    while (1) {
33        usb_poll();
34    }
35}
labsw/fw/regs.h
1#include "regs-f320.h"
labsw/fw/usb-id.h
1/*
2 * labsw/usb-id.h - USB vendor and product ID
3 *
4 * Written 2011 by Werner Almesberger
5 * Copyright 2011 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#ifndef USB_ID_H
15#define USB_ID_H
16
17/*
18 * Platform-specific settings
19 *
20 * USB_VENDOR = Qi Hardware
21 * USB_PRODUCT = 7ab5
22 *
23 * 7ab5 is "LABS" in "leet", http://en.wikipedia.org/wiki/Leet
24 */
25
26#define USB_VENDOR 0x20b7 /* Qi Hardware */
27#define USB_PRODUCT 0x7ab5 /* Lab Switch */
28
29#endif /* !USB_ID_H */

Archive Download the corresponding diff file

Branches:
master



interactive