Skip to content

Commit c066e4d

Browse files
deshiputannewt
authored andcommitted
Add board definition for the uGame handheld console
This is a board definition for the uGame project: https://hackaday.io/project/27629-game uGame is a small handheld game console programmable with CircuitPython. The hardware part of the project is pretty much stable by now.
1 parent f738996 commit c066e4d

File tree

8 files changed

+464
-0
lines changed

8 files changed

+464
-0
lines changed

atmel-samd/boards/ugame/board.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
29+
void board_init(void) {
30+
}
31+
32+
bool board_requests_safe_mode(void) {
33+
return false;
34+
}
35+
36+
void reset_board(void) {
37+
}

atmel-samd/boards/ugame/conf_access.h

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* \file
3+
*
4+
* \brief Memory access control configuration file.
5+
*
6+
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
7+
*
8+
* \asf_license_start
9+
*
10+
* \page License
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions are met:
14+
*
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
*
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
*
22+
* 3. The name of Atmel may not be used to endorse or promote products derived
23+
* from this software without specific prior written permission.
24+
*
25+
* 4. This software may only be redistributed and used in connection with an
26+
* Atmel microcontroller product.
27+
*
28+
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31+
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38+
* POSSIBILITY OF SUCH DAMAGE.
39+
*
40+
* \asf_license_stop
41+
*
42+
*/
43+
/*
44+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45+
*/
46+
47+
#ifndef _CONF_ACCESS_H_
48+
#define _CONF_ACCESS_H_
49+
50+
#include "compiler.h"
51+
#include "board.h"
52+
53+
54+
/*! \name Activation of Logical Unit Numbers
55+
*/
56+
//! @{
57+
#define LUN_0 ENABLE //!< On-Chip Virtual Memory.
58+
#define LUN_1 DISABLE //!< AT45DBX Data Flash.
59+
#define LUN_2 DISABLE //!< SD/MMC Card over SPI.
60+
#define LUN_3 DISABLE //!< SD/MMC Card over MCI Slot 0.
61+
#define LUN_4 DISABLE
62+
#define LUN_5 DISABLE
63+
#define LUN_6 DISABLE
64+
#define LUN_7 DISABLE
65+
#define LUN_USB DISABLE //!< Host Mass-Storage Memory.
66+
//! @}
67+
68+
/*! \name LUN 0 Definitions
69+
*/
70+
//! @{
71+
#define LUN_0_INCLUDE "access_vfs.h"
72+
#define Lun_0_test_unit_ready vfs_test_unit_ready
73+
#define Lun_0_read_capacity vfs_read_capacity
74+
#define Lun_0_unload NULL
75+
#define Lun_0_wr_protect vfs_wr_protect
76+
#define Lun_0_removal vfs_removal
77+
#define Lun_0_usb_read_10 vfs_usb_read_10
78+
#define Lun_0_usb_write_10 vfs_usb_write_10
79+
#define LUN_0_NAME "\"CircuitPython VFS[0]\""
80+
//! @}
81+
82+
#define MEM_USB LUN_USB
83+
84+
/*! \name Actions Associated with Memory Accesses
85+
*
86+
* Write here the action to associate with each memory access.
87+
*
88+
* \warning Be careful not to waste time in order not to disturb the functions.
89+
*/
90+
//! @{
91+
#define memory_start_read_action(nb_sectors)
92+
#define memory_stop_read_action()
93+
#define memory_start_write_action(nb_sectors)
94+
#define memory_stop_write_action()
95+
//! @}
96+
97+
/*! \name Activation of Interface Features
98+
*/
99+
//! @{
100+
#define ACCESS_USB true //!< MEM <-> USB interface.
101+
#define ACCESS_MEM_TO_RAM false //!< MEM <-> RAM interface.
102+
#define ACCESS_STREAM false //!< Streaming MEM <-> MEM interface.
103+
#define ACCESS_STREAM_RECORD false //!< Streaming MEM <-> MEM interface in record mode.
104+
#define ACCESS_MEM_TO_MEM false //!< MEM <-> MEM interface.
105+
#define ACCESS_CODEC false //!< Codec interface.
106+
//! @}
107+
108+
/*! \name Specific Options for Access Control
109+
*/
110+
//! @{
111+
#define GLOBAL_WR_PROTECT false //!< Management of a global write protection.
112+
//! @}
113+
114+
115+
#endif // _CONF_ACCESS_H_

atmel-samd/boards/ugame/conf_board.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* \file
3+
*
4+
* \brief User board configuration template
5+
*
6+
*/
7+
/*
8+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
9+
*/
10+
11+
#ifndef CONF_BOARD_H
12+
#define CONF_BOARD_H
13+
14+
#endif // CONF_BOARD_H

atmel-samd/boards/ugame/conf_clocks.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "conf_clocks_crystalless.h"

atmel-samd/boards/ugame/conf_usb.h

+221
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
5+
#include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
7+
#ifndef CONF_USB_H_INCLUDED
8+
#define CONF_USB_H_INCLUDED
9+
10+
#define USB_DEVICE_MAJOR_VERSION 1
11+
#define USB_DEVICE_MINOR_VERSION 0
12+
#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
13+
#define USB_DEVICE_ATTR \
14+
(USB_CONFIG_ATTR_BUS_POWERED)
15+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
16+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
17+
18+
//! USB Device string definitions (Optional)
19+
#ifndef USB_DEVICE_MANUFACTURE_NAME
20+
# define USB_DEVICE_MANUFACTURE_NAME "Radomir Dopieralski"
21+
#endif
22+
23+
#ifndef USB_DEVICE_PRODUCT_NAME
24+
# define USB_DEVICE_PRODUCT_NAME "uGame"
25+
#endif
26+
// #define USB_DEVICE_SERIAL_NAME "12...EF"
27+
#define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
28+
#define USB_DEVICE_GET_SERIAL_NAME_LENGTH 32
29+
extern char serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
30+
31+
//! Control endpoint size
32+
#define USB_DEVICE_EP_CTRL_SIZE 64
33+
34+
//! Interfaces for this device (CDC COM + CDC DATA + MSC + HID mouse + HID kbd)
35+
#define USB_DEVICE_NB_INTERFACE 5
36+
37+
// (3 | USB_EP_DIR_IN) // CDC Notify endpoint
38+
// (4 | USB_EP_DIR_IN) // CDC TX
39+
// (5 | USB_EP_DIR_OUT) // CDC RX
40+
// (1 | USB_EP_DIR_IN) // MSC IN
41+
// (2 | USB_EP_DIR_OUT) // MSC OUT
42+
// (6 | USB_EP_DIR_IN) // HID mouse report
43+
// (7 | USB_EP_DIR_IN) // HID keyboard report
44+
#define USB_DEVICE_MAX_EP 7
45+
46+
#define UDI_CDC_PORT_NB 1
47+
#define UDI_CDC_ENABLE_EXT(port) mp_cdc_enable(port)
48+
extern bool mp_cdc_enable(uint8_t port);
49+
#define UDI_CDC_DISABLE_EXT(port) mp_cdc_disable(port)
50+
extern void mp_cdc_disable(uint8_t port);
51+
#define UDI_CDC_LOW_RATE
52+
53+
#define UDI_CDC_DEFAULT_RATE 115200
54+
#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
55+
#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
56+
#define UDI_CDC_DEFAULT_DATABITS 8
57+
58+
#define UDI_CDC_RX_NOTIFY(port) usb_rx_notify()
59+
void usb_rx_notify(void);
60+
61+
#define UDI_CDC_SET_CODING_EXT(port,cfg) usb_coding_notify(port, cfg)
62+
void usb_coding_notify(uint8_t port, usb_cdc_line_coding_t* coding);
63+
#define UDI_CDC_SET_DTR_EXT(port,set) usb_dtr_notify(port, set)
64+
void usb_dtr_notify(uint8_t port, bool set);
65+
#define UDI_CDC_SET_RTS_EXT(port,set) usb_rts_notify(port, set)
66+
void usb_rts_notify(uint8_t port, bool set);
67+
68+
/**
69+
* USB CDC low level configuration
70+
* In standalone these configurations are defined by the CDC module.
71+
* For composite device, these configuration must be defined here
72+
* @{
73+
*/
74+
//! Endpoint numbers definition
75+
76+
#define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint
77+
#define UDI_CDC_DATA_EP_IN_0 (4 | USB_EP_DIR_IN) // TX
78+
#define UDI_CDC_DATA_EP_OUT_0 (5 | USB_EP_DIR_OUT) // RX
79+
80+
//! Interface numbers
81+
#define UDI_CDC_COMM_IFACE_NUMBER_0 0
82+
#define UDI_CDC_DATA_IFACE_NUMBER_0 1
83+
84+
/**
85+
* Configuration of MSC interface
86+
* @{
87+
*/
88+
//! Vendor name and Product version of MSC interface
89+
#define UDI_MSC_GLOBAL_VENDOR_ID \
90+
'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
91+
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
92+
'1', '.', '0', '0'
93+
94+
//! Interface callback definition
95+
#define UDI_MSC_ENABLE_EXT() mp_msc_enable()
96+
extern bool mp_msc_enable(void);
97+
#define UDI_MSC_DISABLE_EXT() mp_msc_disable()
98+
extern void mp_msc_disable(void);
99+
100+
//! Enable id string of interface to add an extra USB string
101+
#define UDI_MSC_STRING_ID 5
102+
103+
/**
104+
* USB MSC low level configuration
105+
* In standalone these configurations are defined by the MSC module.
106+
* For composite device, these configuration must be defined here
107+
* @{
108+
*/
109+
//! Endpoint numbers definition
110+
#define UDI_MSC_EP_IN (1 | USB_EP_DIR_IN)
111+
#define UDI_MSC_EP_OUT (2 | USB_EP_DIR_OUT)
112+
113+
//! Interface number
114+
#define UDI_MSC_IFACE_NUMBER 2
115+
/**
116+
* Configuration of HID Mouse interface
117+
* @{
118+
*/
119+
//! Interface callback definition
120+
#define UDI_HID_MOUSE_ENABLE_EXT() mp_mouse_enable()
121+
extern bool mp_mouse_enable(void);
122+
#define UDI_HID_MOUSE_DISABLE_EXT() mp_mouse_disable()
123+
extern void mp_mouse_disable(void);
124+
125+
//! Enable id string of interface to add an extra USB string
126+
#define UDI_HID_MOUSE_STRING_ID 6
127+
128+
/**
129+
* USB HID Mouse low level configuration
130+
* In standalone these configurations are defined by the HID Mouse module.
131+
* For composite device, these configuration must be defined here
132+
* @{
133+
*/
134+
//! Endpoint numbers definition
135+
#define UDI_HID_MOUSE_EP_IN (6 | USB_EP_DIR_IN)
136+
137+
//! Interface number
138+
#define UDI_HID_MOUSE_IFACE_NUMBER 3
139+
//@}
140+
//@}
141+
142+
/**
143+
* Configuration of HID Keyboard interface
144+
* @{
145+
*/
146+
//! Interface callback definition
147+
#define UDI_HID_KBD_ENABLE_EXT() mp_keyboard_enable()
148+
extern bool mp_keyboard_enable(void);
149+
#define UDI_HID_KBD_DISABLE_EXT() mp_keyboard_disable()
150+
extern void mp_keyboard_disable(void);
151+
#define UDI_HID_KBD_CHANGE_LED(value) mp_keyboard_led(value)
152+
extern void mp_keyboard_led(uint8_t);
153+
154+
//! Enable id string of interface to add an extra USB string
155+
#define UDI_HID_KBD_STRING_ID 7
156+
157+
/**
158+
* USB HID Keyboard low level configuration
159+
* In standalone these configurations are defined by the HID Keyboard module.
160+
* For composite device, these configuration must be defined here
161+
* @{
162+
*/
163+
//! Endpoint numbers definition
164+
#define UDI_HID_KBD_EP_IN (7 | USB_EP_DIR_IN)
165+
166+
//! Interface number
167+
#define UDI_HID_KBD_IFACE_NUMBER 4
168+
169+
/**
170+
* Description of Composite Device
171+
* @{
172+
*/
173+
//! USB Interfaces descriptor structure
174+
#define UDI_COMPOSITE_DESC_T \
175+
usb_iad_desc_t udi_cdc_iad; \
176+
udi_cdc_comm_desc_t udi_cdc_comm; \
177+
udi_cdc_data_desc_t udi_cdc_data; \
178+
udi_msc_desc_t udi_msc; \
179+
udi_hid_mouse_desc_t udi_hid_mouse; \
180+
udi_hid_kbd_desc_t udi_hid_kbd
181+
182+
//! USB Interfaces descriptor value for Full Speed
183+
#define UDI_COMPOSITE_DESC_FS \
184+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
185+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
186+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
187+
.udi_msc = UDI_MSC_DESC_FS, \
188+
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
189+
.udi_hid_kbd = UDI_HID_KBD_DESC
190+
191+
//! USB Interfaces descriptor value for High Speed
192+
#define UDI_COMPOSITE_DESC_HS \
193+
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
194+
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
195+
.udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
196+
.udi_msc = UDI_MSC_DESC_HS, \
197+
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
198+
.udi_hid_kbd = UDI_HID_KBD_DESC
199+
200+
//! USB Interface APIs
201+
#define UDI_COMPOSITE_API \
202+
&udi_api_cdc_comm, \
203+
&udi_api_cdc_data, \
204+
&udi_api_msc, \
205+
&udi_api_hid_mouse, \
206+
&udi_api_hid_kbd
207+
//@}
208+
209+
/**
210+
* USB Device Driver Configuration
211+
* @{
212+
*/
213+
//@}
214+
215+
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
216+
#include "udi_cdc.h"
217+
#include "udi_msc.h"
218+
#include "udi_hid_mouse.h"
219+
#include "udi_hid_kbd.h"
220+
221+
#endif

0 commit comments

Comments
 (0)