move to targets dir

This commit is contained in:
Conor Patrick
2018-09-12 20:00:13 -04:00
parent c4cb2deb5a
commit 364e552ae9
81 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
//=========================================================
// inc/InitDevice.h: generated by Hardware Configurator
//
// This file will be regenerated when saving a document.
// leave the sections inside the "$[...]" comment tags alone
// or they will be overwritten!
//=========================================================
#ifndef __INIT_DEVICE_H__
#define __INIT_DEVICE_H__
// USER CONSTANTS
// USER PROTOTYPES
// $[Mode Transition Prototypes]
extern void enter_DefaultMode_from_RESET(void);
// [Mode Transition Prototypes]$
// $[Config(Per-Module Mode)Transition Prototypes]
extern void WDT_0_enter_DefaultMode_from_RESET(void);
extern void PORTS_0_enter_DefaultMode_from_RESET(void);
extern void PORTS_1_enter_DefaultMode_from_RESET(void);
extern void PBCFG_0_enter_DefaultMode_from_RESET(void);
extern void LFOSC_0_enter_DefaultMode_from_RESET(void);
extern void CIP51_0_enter_DefaultMode_from_RESET(void);
extern void CLOCK_0_enter_DefaultMode_from_RESET(void);
extern void TIMER01_0_enter_DefaultMode_from_RESET(void);
extern void TIMER16_2_enter_DefaultMode_from_RESET(void);
extern void TIMER16_3_enter_DefaultMode_from_RESET(void);
extern void TIMER_SETUP_0_enter_DefaultMode_from_RESET(void);
extern void SPI_0_enter_DefaultMode_from_RESET(void);
extern void UART_0_enter_DefaultMode_from_RESET(void);
extern void INTERRUPT_0_enter_DefaultMode_from_RESET(void);
extern void USBLIB_0_enter_DefaultMode_from_RESET(void);
// [Config(Per-Module Mode)Transition Prototypes]$
#endif

33
targets/efm8/inc/app.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* app.h
*
* Created on: Jun 25, 2018
* Author: conor
*/
#ifndef INC_APP_H_
#define INC_APP_H_
#define USE_PRINTING
void usb_transfer_complete();
void spi_transfer_complete();
#define INPUT_ENDPOINT EP2OUT
#define OUTPUT_ENDPOINT EP3IN
#define INPUT_ENDPOINT_NUM 0x83
#define OUTPUT_ENDPOINT_NUM 0x02
//#define INPUT_ENDPOINT EP1OUT
//#define OUTPUT_ENDPOINT EP1IN
//
//#define INPUT_ENDPOINT_NUM 0x81
//#define OUTPUT_ENDPOINT_NUM 0x01
void delay(int ms);
#endif /* INC_APP_H_ */

View File

@@ -0,0 +1,157 @@
/*******************************************************************************
* @file usbconfig.h
* @brief USB protocol stack library, application supplied configuration options.
*******************************************************************************/
//=============================================================================
// inc/config/usbconfig.h: generated by Hardware Configurator
//
// This file will be regenerated when saving a document. leave the sections
// inside the "$[...]" comment tags alone or they will be overwritten!
//=============================================================================
#ifndef __SILICON_LABS_USBCONFIG_H
#define __SILICON_LABS_USBCONFIG_H
// -----------------------------------------------------------------------------
// Specify bus- or self-powered
// -----------------------------------------------------------------------------
// $[Device Power]
#define SLAB_USB_BUS_POWERED 1
// [Device Power]$
// -----------------------------------------------------------------------------
// Specify USB speed
// -----------------------------------------------------------------------------
// $[USB Speed]
#define SLAB_USB_FULL_SPEED 1
// [USB Speed]$
// -----------------------------------------------------------------------------
// Enable or disable the clock recovery
// -----------------------------------------------------------------------------
// $[Clock Recovery]
#define SLAB_USB_CLOCK_RECOVERY_ENABLED 1
// [Clock Recovery]$
// -----------------------------------------------------------------------------
// Enable or disable remote wakeup
// -----------------------------------------------------------------------------
// $[Remote Wake-up]
#define SLAB_USB_REMOTE_WAKEUP_ENABLED 0
// [Remote Wake-up]$
// -----------------------------------------------------------------------------
// Specify number of interfaces and whether any interfaces support alternate
// settings
// -----------------------------------------------------------------------------
// $[Number of Interfaces]
#define SLAB_USB_NUM_INTERFACES 1
#define SLAB_USB_SUPPORT_ALT_INTERFACES 0
// [Number of Interfaces]$
// -----------------------------------------------------------------------------
// Enable or disable each endpoint
// -----------------------------------------------------------------------------
// $[Endpoints Used]
#define SLAB_USB_EP1IN_USED 0
#define SLAB_USB_EP1OUT_USED 0
#define SLAB_USB_EP2IN_USED 0
#define SLAB_USB_EP2OUT_USED 1
#define SLAB_USB_EP3IN_USED 1
#define SLAB_USB_EP3OUT_USED 0
// [Endpoints Used]$
// -----------------------------------------------------------------------------
// Specify maximum packet size for each endpoint
// -----------------------------------------------------------------------------
// $[Endpoint Max Packet Size]
#define SLAB_USB_EP1IN_MAX_PACKET_SIZE 64
#define SLAB_USB_EP1OUT_MAX_PACKET_SIZE 64
#define SLAB_USB_EP2IN_MAX_PACKET_SIZE 64
#define SLAB_USB_EP2OUT_MAX_PACKET_SIZE 64
#define SLAB_USB_EP3IN_MAX_PACKET_SIZE 64
#define SLAB_USB_EP3OUT_MAX_PACKET_SIZE 1
// [Endpoint Max Packet Size]$
// -----------------------------------------------------------------------------
// Specify transfer type of each endpoint
// -----------------------------------------------------------------------------
// $[Endpoint Transfer Type]
#define SLAB_USB_EP1IN_TRANSFER_TYPE USB_EPTYPE_INTR
#define SLAB_USB_EP1OUT_TRANSFER_TYPE USB_EPTYPE_INTR
#define SLAB_USB_EP2IN_TRANSFER_TYPE USB_EPTYPE_INTR
#define SLAB_USB_EP2OUT_TRANSFER_TYPE USB_EPTYPE_INTR
#define SLAB_USB_EP3IN_TRANSFER_TYPE USB_EPTYPE_INTR
#define SLAB_USB_EP3OUT_TRANSFER_TYPE USB_EPTYPE_ISOC
// [Endpoint Transfer Type]$
// -----------------------------------------------------------------------------
// Enable or disable callback functions
// -----------------------------------------------------------------------------
// $[Callback Functions]
#define SLAB_USB_HANDLER_CB 0
#define SLAB_USB_IS_SELF_POWERED_CB 1
#define SLAB_USB_RESET_CB 1
#define SLAB_USB_SETUP_CMD_CB 1
#define SLAB_USB_SOF_CB 0
#define SLAB_USB_STATE_CHANGE_CB 1
// [Callback Functions]$
// -----------------------------------------------------------------------------
// Specify number of languages supported by string descriptors.
// -----------------------------------------------------------------------------
// $[Number of Languages]
#define SLAB_USB_NUM_LANGUAGES 1
// [Number of Languages]$
// -----------------------------------------------------------------------------
// If only one descriptor language is supported, specify that language here.
// If multiple descriptor languages are supported, this value is ignored and
// the supported languages must listed in the
// myUsbStringTableLanguageIDsDescriptor structure.
// -----------------------------------------------------------------------------
// $[USB Language]
#define SLAB_USB_LANGUAGE USB_LANGID_ENUS
// [USB Language]$
// -----------------------------------------------------------------------------
//
// Set the power saving mode
//
// SLAB_USB_PWRSAVE_MODE configures when the device will automatically enter
// the USB power-save mode. It is a bitmask constant with bit values:
// USB_PWRSAVE_MODE_OFF - No energy saving mode selected
// USB_PWRSAVE_MODE_ONSUSPEND - Enter USB power-save mode on USB suspend
// USB_PWRSAVE_MODE_ONVBUSOFF - Enter USB power-save mode when not attached
// to the USB host.
// USB_PWRSAVE_MODE_FASTWAKE - Exit USB power-save mode more quickly, but
// consume more power while in USB power-save
// mode.
// While the device is in USB power-save mode
// (typically during USB suspend), the
// internal voltage regulator stays in normal
// power mode instead of entering suspend
// power mode.
// This is an advanced feature that may be
// useful in certain applications that support
// remote wakeup.
//
// -----------------------------------------------------------------------------
// $[Power Save Mode]
#define SLAB_USB_PWRSAVE_MODE USB_PWRSAVE_MODE_OFF
// [Power Save Mode]$
// -----------------------------------------------------------------------------
// Enable or disable polled mode
//
// When enabled, the application must call USBD_Run() periodically to process
// USB events.
// When disabled, USB events will be handled automatically by an interrupt
// handler.
// -----------------------------------------------------------------------------
// $[Polled Mode]
#define SLAB_USB_POLLED_MODE 0
// [Polled Mode]$
#endif // __SILICON_LABS_USBCONFIG_H

View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* @file descriptors.h
* @brief USB descriptors header file.
*******************************************************************************/
//=============================================================================
// inc/descriptors.h: generated by Hardware Configurator
//
// This file will be regenerated when saving a document. leave the sections
// inside the "$[...]" comment tags alone or they will be overwritten!
//=============================================================================
#ifndef __SILICON_LABS_DESCRIPTORS_H
#define __SILICON_LABS_DESCRIPTORS_H
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <si_toolchain.h>
#include <endian.h>
#include <stdlib.h>
#include <string.h>
#include <efm8_usb.h>
#ifdef __cplusplus
extern "C" {
#endif
// -------------------- USB Identification ------------------------------------
//
// **********
// NOTE: YOU MUST PROVIDE YOUR OWN USB VID/PID (below)
// **********
//
// Following are the definition of the USB VID and PID. These are, by default,
// values that are assigned to Silicon Labs. These values are provided merely
// as an example. You may not use the Silicon Labs VID/PID values in your
// product. You must provide your own assigned VID and PID values.
//-----------------------------------------------------------------------------
// $[Vendor ID]
#define USB_VENDOR_ID htole16(0x10c4)
// [Vendor ID]$
// $[Product ID]
#define USB_PRODUCT_ID htole16(0x8acf)
// [Product ID]$
extern SI_SEGMENT_VARIABLE(ReportDescriptor0[34], const uint8_t, SI_SEG_CODE);
extern SI_SEGMENT_VARIABLE(deviceDesc[], const USB_DeviceDescriptor_TypeDef, SI_SEG_CODE);
extern SI_SEGMENT_VARIABLE(configDesc[], const uint8_t, SI_SEG_CODE);
extern SI_SEGMENT_VARIABLE(initstruct, const USBD_Init_TypeDef, SI_SEG_CODE);
#define HID_PACKET_SIZE 64
#ifdef __cplusplus
}
#endif
#endif // __SILICON_LABS_DESCRIPTORS_H
#if 0
// $[HID Report Descriptors]
extern SI_SEGMENT_VARIABLE(ReportDescriptor0[0], const uint8_t, SI_SEG_CODE);
// [HID Report Descriptors]$
#endif

19
targets/efm8/inc/eeprom.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef EEPROM_H_
#define EEPROM_H_
#include "app.h"
void eeprom_init();
void eeprom_read(uint16_t addr, uint8_t * buf, uint8_t len);
void _eeprom_write(uint16_t addr, uint8_t * buf, uint8_t len, uint8_t flags);
extern char __erase_mem[3];
#define eeprom_write(a,b,l) _eeprom_write(a,b,l,0x1)
#define eeprom_erase(a) _eeprom_write(a,__erase_mem,1,0x3)
#define EEPROM_DATA_START 0xF800
#endif /* EEPROM_H_ */

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2016, Conor Patrick
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PRINTING_H_
#define PRINTING_H_
#include <SI_EFM8UB1_Register_Enums.h>
#include <efm8_usb.h>
#include <stdint.h>
#include "app.h"
#define watchdog() (WDTCN = 0xA5)
#define reboot() (RSTSRC = 1 << 4)
#define millis() ((uint16_t)(TMR3L | (TMR3H << 8)))
void u2f_delay(uint32_t ms);
void usb_write();
#ifdef USE_PRINTING
void dump_hex(uint8_t* hex, uint8_t len);
void cputd(uint32_t i);
void cputx(uint32_t i);
#define cputb(x) cputx((uint8_t) (x))
#define cputl(x) cputd((uint32_t) (x))
#define cputlx(x) cputx((uint32_t) (x))
void cprints(const char * str);
void cprintb(const char * tag, uint8_t c, ...);
void cprintd(const char * tag, uint8_t c, ...);
void cprintx(const char * tag, uint8_t c, ...);
void cprintl(const char * tag, uint8_t c, ...);
void cprintlx(const char * tag, uint8_t c, ...);
#else
#define cprintx(x)
#define cprintb(x)
#define cprintlx(x)
#define cprintl(x)
#define cprintd(x)
#define cprints(x)
#define cputx(x)
#define cputb(x)
#define cputl(x)
#define cputlx(x)
#define putf(x)
#define dump_hex(x)
#endif
#endif /* BSP_H_ */