├── .gitignore ├── .project ├── Arduino_Support.cywrk ├── Bootloader.cydsn ├── Bootloader.cydwr ├── Bootloader.cyprj ├── Bootloader_v1_30 │ ├── Bootloader_v1_30.cystate │ ├── Bootloader_v1_30.cysym │ ├── Bootloader_v1_30.pdf │ ├── Custom │ │ ├── Properties │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── cycustomizer.cs │ │ ├── cygeneralpage.Designer.cs │ │ ├── cygeneralpage.cs │ │ ├── cygeneralpage.resx │ │ ├── cyparameters.cs │ │ └── cywrappercontrol.cs │ └── PSoC5 │ │ └── API │ │ ├── Bootloader.c │ │ ├── Bootloader.h │ │ └── Bootloader_PVT.h ├── TopDesign │ └── TopDesign.cysch ├── device.h └── main.c ├── FreeSoC2_ST.cydsn ├── FreeSoC2_ST.cydwr ├── FreeSoC2_ST.cyprj ├── FreeSoC2_ST.cyversion ├── TopDesign │ ├── TopDesign.cysch │ ├── TopDesign.cysym │ └── TopDesign_01.cymacro └── main.c ├── Hardware └── SparkFun │ └── psoc │ ├── Bootloader.hex │ ├── avrdude.conf │ ├── boards.txt │ ├── cores │ └── arduino │ │ ├── ADC.h │ │ ├── ADC_IRQ.h │ │ ├── ADC_Mux.h │ │ ├── ADC_theACLK.h │ │ ├── A_aliases.h │ │ ├── Arduino.h │ │ ├── Arduino_Advanced_IO.cpp │ │ ├── Arduino_Advanced_IO.h │ │ ├── Arduino_Analog_In.cpp │ │ ├── Arduino_Analog_In.h │ │ ├── Arduino_Analog_Out.cpp │ │ ├── Arduino_Analog_Out.h │ │ ├── Arduino_Extended_IO.h │ │ ├── Arduino_HW_Interrupt.cpp │ │ ├── Arduino_HW_Interrupt.h │ │ ├── Arduino_Math.cpp │ │ ├── Arduino_Pins.cpp │ │ ├── Arduino_Pins.h │ │ ├── Arduino_Random.cpp │ │ ├── Arduino_Random.h │ │ ├── Arduino_Serial.cpp │ │ ├── Arduino_Serial.h │ │ ├── Arduino_Time.cpp │ │ ├── Arduino_Time.h │ │ ├── Arduino_Tone.cpp │ │ ├── Arduino_Tone.h │ │ ├── Bootloadable.h │ │ ├── BootloaderResetInterrupt.h │ │ ├── BootloaderResetTimer.h │ │ ├── Client.h │ │ ├── Clock_12.h │ │ ├── Clock_2.h │ │ ├── Clock_3.h │ │ ├── Clock_5.h │ │ ├── Cm3Start.c │ │ ├── CyBootAsmGnu.S │ │ ├── CyDmac.h │ │ ├── CyFlash.h │ │ ├── CyLib.h │ │ ├── CySpc.h │ │ ├── D10_Ctrl.h │ │ ├── D11_Ctrl.h │ │ ├── DA.h │ │ ├── DA_aliases.h │ │ ├── DB_aliases.h │ │ ├── HW_INT.h │ │ ├── HardwareSerial.h │ │ ├── I2C.h │ │ ├── I2C_Enable.h │ │ ├── I2C_PVT.h │ │ ├── IPAddress.cpp │ │ ├── IPAddress.h │ │ ├── Micros_Counter.h │ │ ├── Millis_Counter.h │ │ ├── P0_aliases.h │ │ ├── P12_aliases.h │ │ ├── P3_aliases.h │ │ ├── P4_aliases.h │ │ ├── P5_aliases.h │ │ ├── PRS.h │ │ ├── PWM_1.h │ │ ├── PWM_2.h │ │ ├── PWM_3.h │ │ ├── Print.cpp │ │ ├── Print.h │ │ ├── Printable.h │ │ ├── SPIM_0.h │ │ ├── SPIM_0_PVT.h │ │ ├── SPIM_1.h │ │ ├── SPIM_1_PVT.h │ │ ├── SPI_Clock_In.h │ │ ├── SPI_MODE_REG.h │ │ ├── Server.h │ │ ├── ServoCounter.h │ │ ├── ServoInterrupt.h │ │ ├── Stream.cpp │ │ ├── Stream.h │ │ ├── ToneTimer.h │ │ ├── Tone_Interrupt.h │ │ ├── UART.h │ │ ├── UARTClass.cpp │ │ ├── UARTClass.h │ │ ├── UART_Clock.h │ │ ├── USBUART.h │ │ ├── USBUART_Dm.h │ │ ├── USBUART_Dm_aliases.h │ │ ├── USBUART_Dp.h │ │ ├── USBUART_Dp_aliases.h │ │ ├── USBUART_audio.h │ │ ├── USBUART_cdc.h │ │ ├── USBUART_hid.h │ │ ├── USBUART_midi.h │ │ ├── USBUART_pvt.h │ │ ├── Udp.h │ │ ├── UserButton.h │ │ ├── UserButton_aliases.h │ │ ├── WCharacter.h │ │ ├── WMath.cpp │ │ ├── WMath.h │ │ ├── WString.cpp │ │ ├── WString.h │ │ ├── avr │ │ ├── dtostrf.c │ │ ├── dtostrf.h │ │ └── pgmspace.h │ │ ├── binary.h │ │ ├── cm3gcc.ld │ │ ├── core_cm3.h │ │ ├── core_cm3_psoc5.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── cyPm.h │ │ ├── cydevice.h │ │ ├── cydevice_trm.h │ │ ├── cydevicegnu.inc │ │ ├── cydevicegnu_trm.inc │ │ ├── cydisabledsheets.h │ │ ├── cyfitter.h │ │ ├── cyfitter_cfg.h │ │ ├── cyfittergnu.inc │ │ ├── cypins.h │ │ ├── cytypes.h │ │ ├── itoa.c │ │ ├── itoa.h │ │ ├── main.cpp │ │ └── project.h │ ├── drivers │ ├── KitProg.inf │ ├── KitProgUSBUART.inf │ ├── PSoCUSB3.sys │ ├── USBUART_cdc.inf │ ├── WdfCoInstaller01009.dll │ ├── kitproguart.cat │ └── psocusb3.cat │ ├── libraries │ ├── SPI │ │ ├── SPI.cpp │ │ └── SPI.h │ ├── Servo │ │ ├── .Servo.cpp.swp │ │ ├── .Servo.h.swp │ │ ├── Servo.cpp │ │ └── Servo.h │ ├── WS281x │ │ ├── WS281x.cpp │ │ └── WS281x.h │ └── Wire │ │ ├── Arduino_I2C.cpp │ │ ├── Arduino_I2C.h │ │ └── Wire.h │ ├── platform.txt │ ├── programmers.txt │ └── variants │ └── standard │ ├── CyCompLib.a │ ├── Uno_blocks.a │ ├── pins_arduino.h │ ├── variant.cpp │ └── variant.h ├── README.md └── tags /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore list for Eagle, a PCB layout tool 2 | 3 | # Backup files 4 | *.s#? 5 | *.b#? 6 | *.l#? 7 | 8 | # Eagle project file 9 | # It contains a serial number and references to the file structure 10 | # on your computer. 11 | # comment the following line if you want to have your project file included. 12 | eagle.epf 13 | 14 | # CAM files 15 | *.$$$ 16 | *.cmp 17 | *.ly2 18 | *.l15 19 | *.sol 20 | *.plc 21 | *.stc 22 | *.sts 23 | *.crc 24 | *.crs 25 | 26 | *.dri 27 | *.drl 28 | *.gpi 29 | *.pls 30 | 31 | *.drd 32 | *.drd.* 33 | 34 | *.info 35 | 36 | *.eps 37 | 38 | *.cywrk.* 39 | ComponentUpdateLog.txt 40 | codegentemp/ 41 | Export/ 42 | CortexM3/ 43 | DP8051/ 44 | Generated_Source/ 45 | *.svd 46 | *.html 47 | *.rpt 48 | *.cyprj.* 49 | *.cycdx 50 | *.cyfit 51 | Uno_Blocks.cydsn/Libraries/APDS9960 52 | Uno_Blocks.cydsn/Libraries/MicroOLED 53 | Uno_Blocks.cydsn/Libraries/WiFi 54 | 55 | -------------------------------------------------------------------------------- /Arduino_Support.cywrk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | .\Bootloader.cydsn\Bootloader.cyprj 11 | .\FreeSoC2.cydsn\FreeSoC2.cyprj 12 | .\FreeSoC2_ST.cydsn\FreeSoC2_ST.cyprj 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader.cydwr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Bootloader.cydsn/Bootloader.cydwr -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader_v1_30/Bootloader_v1_30.cystate: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | PSoC3 6 | * 7 | * 8 | * 9 | 10 | Production 11 | None 12 | 13 | 14 | 15 | 16 | PSoC4 17 | * 18 | * 19 | * 20 | 21 | Production 22 | None 23 | 24 | 25 | 26 | 27 | PSoC5 28 | PSoC5LP 29 | 30 | Production 31 | None 32 | 33 | 34 | -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader_v1_30/Bootloader_v1_30.cysym: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Bootloader.cydsn/Bootloader_v1_30/Bootloader_v1_30.cysym -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader_v1_30/Bootloader_v1_30.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Bootloader.cydsn/Bootloader_v1_30/Bootloader_v1_30.pdf -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader_v1_30/Custom/cywrappercontrol.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2012-2014, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | using System.Windows.Forms; 12 | using CyDesigner.Extensions.Gde; 13 | using CyDesigner.Extensions.Common; 14 | 15 | namespace Bootloader_v1_30 16 | { 17 | /// 18 | /// Wrapper for tabs 19 | /// 20 | public class CyEditingWrapperControl : UserControl, ICyParamEditingControl 21 | { 22 | protected CyParameters m_parameters = null; 23 | 24 | public virtual string TabName 25 | { 26 | get { return "Empty"; } 27 | } 28 | 29 | public CyEditingWrapperControl() { } 30 | 31 | public CyEditingWrapperControl(CyParameters parameters) 32 | { 33 | m_parameters = parameters; 34 | this.Load += new EventHandler(CyEditingWrapperControl_Load); 35 | } 36 | 37 | void CyEditingWrapperControl_Load(object sender, EventArgs e) 38 | { 39 | this.AutoScroll = true; 40 | this.Dock = DockStyle.Fill; 41 | } 42 | 43 | #region ICyParamEditingControl Members 44 | public Control DisplayControl 45 | { 46 | get { return this; } 47 | } 48 | 49 | // Gets any errors that exist for parameters on the DisplayControl. 50 | public virtual IEnumerable GetErrors() 51 | { 52 | foreach (string paramName in m_parameters.InstQuery.GetParamNames()) 53 | { 54 | CyCompDevParam param = m_parameters.InstQuery.GetCommittedParam(paramName); 55 | if (param.TabName.Equals(TabName)) 56 | { 57 | if (param.ErrorCount > 0) 58 | { 59 | foreach (string errMsg in param.Errors) 60 | { 61 | yield return new CyCustErr(errMsg); 62 | } 63 | } 64 | } 65 | } 66 | 67 | } 68 | #endregion 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Bootloader.cydsn/Bootloader_v1_30/PSoC5/API/Bootloader.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Bootloader.h 3 | * Version 1.30 4 | * 5 | * Description: 6 | * Provides an API for the Bootloader. The API includes functions for starting 7 | * boot loading operations, validating the application and jumping to the 8 | * application. 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_BOOTLOADER_Bootloader_H) 18 | #define CY_BOOTLOADER_Bootloader_H 19 | 20 | #include "cytypes.h" 21 | #include "CyFlash.h" 22 | 23 | 24 | #define APPLICATION_START_ADDRESS 0x00002811 25 | 26 | /******************************************************************************* 27 | * Bootloadable applications identification 28 | *******************************************************************************/ 29 | /* Mask used to indicate starting application */ 30 | #define Bootloader_SCHEDULE_BTLDB (0x80u) 31 | #define Bootloader_NEW_BOOT (0x00u) 32 | #define Bootloader_SCHEDULE_BTLDR (0x40u) 33 | #define Bootloader_START_BTLDB (0x80u) 34 | #define Bootloader_START_BTLDR (0x40u) 35 | #define Bootloader_SCHEDULE_MASK (0xC0u) 36 | 37 | __attribute__((section (".bootloader"))) 38 | extern const uint8 CYCODE Bootloader_Checksum; 39 | extern const uint8 CYCODE *Bootloader_ChecksumAccess; 40 | 41 | __attribute__((section (".bootloader"))) 42 | extern const uint32 CYCODE Bootloader_SizeBytes; 43 | extern const uint32 CYCODE *Bootloader_SizeBytesAccess; 44 | 45 | /******************************************************************************* 46 | * This variable is used by Bootloader/Bootloadable components to schedule what 47 | * application will be started after software reset. 48 | *******************************************************************************/ 49 | #define Bootloader_RESET_SR0_REG (* (reg8 *) CYREG_RESET_SR0) 50 | #define Bootloader_RESET_SR0_PTR ( (reg8 *) CYREG_RESET_SR0) 51 | 52 | /******************************************************************************* 53 | * Get the reason of the device reset 54 | * Return cyBtldrRunType in the case if software reset was the reset reason and 55 | * set cyBtldrRunType to zero (bootloader application is scheduled - that is 56 | * the initial clean state) and return zero. 57 | *******************************************************************************/ 58 | #define Bootloader_GET_RUN_TYPE \ 59 | (Bootloader_RESET_SR0_REG & Bootloader_SCHEDULE_MASK) 60 | 61 | /******************************************************************************* 62 | * Schedule Bootloader/Bootloadable to be run after software reset 63 | *******************************************************************************/ 64 | #define Bootloader_SET_RUN_TYPE(x) (Bootloader_RESET_SR0_REG = (x)) 65 | 66 | /* Returns the number of Flash arrays available in the device */ 67 | #ifndef CY_FLASH_NUMBER_ARRAYS 68 | #define CY_FLASH_NUMBER_ARRAYS (CYDEV_FLASH_SIZE / CYDEV_FLS_SECTOR_SIZE) 69 | #endif /* CY_FLASH_NUMBER_ARRAYS */ 70 | 71 | /******************************************************************************* 72 | * External References 73 | *******************************************************************************/ 74 | void Bootloader_SetFlashByte(uint32 address, uint8 runType); 75 | void CyBtldr_CheckLaunch(void) CYSMALL ; 76 | void Bootloader_Start(uint32 timeout) CYSMALL ; 77 | void Bootloader_Exit(uint8 appId) CYSMALL ; 78 | 79 | #if(CY_PSOC3) 80 | /* Implementation for the PSoC 3 resides in a Bootloader_psoc3.a51 file. */ 81 | void Bootloader_LaunchBootloadable(uint32 appAddr); 82 | #endif /* (CY_PSOC3) */ 83 | extern void CyBtldrCommStart(void); 84 | extern cystatus CyBtldrCommWrite(uint8* buffer, uint16 size, uint16* count, uint8 timeOut); 85 | extern cystatus CyBtldrCommRead (uint8* buffer, uint16 size, uint16* count, uint8 timeOut); 86 | 87 | #endif /* CY_BOOTLOADER_Bootloader_H */ 88 | 89 | 90 | /* [] END OF FILE */ 91 | -------------------------------------------------------------------------------- /Bootloader.cydsn/TopDesign/TopDesign.cysch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Bootloader.cydsn/TopDesign/TopDesign.cysch -------------------------------------------------------------------------------- /Bootloader.cydsn/device.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is automatically generated by PSoC Creator 3 | * and should not be edited by hand. 4 | * 5 | * This file is necessary for your project to build. 6 | * Please do not delete it. 7 | ******************************************************************************** 8 | * Copyright 2008-2011, Cypress Semiconductor Corporation. All rights reserved. 9 | * You may use this file only in accordance with the license, terms, conditions, 10 | * disclaimers, and limitations in the end user license agreement accompanying 11 | * the software package with which this file was provided. 12 | *******************************************************************************/ 13 | #ifndef DEVICE_H 14 | #define DEVICE_H 15 | #include 16 | 17 | #endif 18 | /* [] END OF FILE */ 19 | -------------------------------------------------------------------------------- /FreeSoC2_ST.cydsn/FreeSoC2_ST.cydwr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/FreeSoC2_ST.cydsn/FreeSoC2_ST.cydwr -------------------------------------------------------------------------------- /FreeSoC2_ST.cydsn/FreeSoC2_ST.cyversion: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FreeSoC2_ST.cydsn/TopDesign/TopDesign.cysch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/FreeSoC2_ST.cydsn/TopDesign/TopDesign.cysch -------------------------------------------------------------------------------- /FreeSoC2_ST.cydsn/TopDesign/TopDesign.cysym: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/FreeSoC2_ST.cydsn/TopDesign/TopDesign.cysym -------------------------------------------------------------------------------- /FreeSoC2_ST.cydsn/TopDesign/TopDesign_01.cymacro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/FreeSoC2_ST.cydsn/TopDesign/TopDesign_01.cymacro -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/boards.txt: -------------------------------------------------------------------------------- 1 | psoc.name=PSoC Dev Board 2 | psoc.upload.tool=avrdude 3 | 4 | psoc.vid=0x2341 5 | psoc.pid=0x003d 6 | psoc.upload.protocol=avr109 7 | psoc.upload.maximum_size=256000 8 | psoc.upload.use_1200bps_touch=true 9 | psoc.upload.wait_for_upload_port=true 10 | psoc.upload.disable_flushing=true 11 | psoc.upload.native_usb=false 12 | psoc.build.mcu=cortex-m3 13 | psoc.build.f_cpu=64000000L 14 | psoc.build.usb_product="FreeSoC2 - Standard" 15 | psoc.build.board=psoc 16 | psoc.build.core=arduino 17 | psoc.build.extra_flags= 18 | psoc.build.ldscript=cm3gcc.ld 19 | psoc.build.variant=standard 20 | psoc.build.variant_system_lib=CyCompLib.a 21 | psoc.build.vid=0x2341 22 | psoc.build.pid=0x003e 23 | 24 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/ADC_IRQ.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: ADC_IRQ.h 3 | * Version 1.70 4 | * 5 | * Description: 6 | * Provides the function definitions for the Interrupt Controller. 7 | * 8 | * 9 | ******************************************************************************** 10 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 11 | * You may use this file only in accordance with the license, terms, conditions, 12 | * disclaimers, and limitations in the end user license agreement accompanying 13 | * the software package with which this file was provided. 14 | *******************************************************************************/ 15 | #if !defined(CY_ISR_ADC_IRQ_H) 16 | #define CY_ISR_ADC_IRQ_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | /* Interrupt Controller API. */ 23 | void ADC_IRQ_Start(void); 24 | void ADC_IRQ_StartEx(cyisraddress address); 25 | void ADC_IRQ_Stop(void); 26 | 27 | CY_ISR_PROTO(ADC_IRQ_Interrupt); 28 | 29 | void ADC_IRQ_SetVector(cyisraddress address); 30 | cyisraddress ADC_IRQ_GetVector(void); 31 | 32 | void ADC_IRQ_SetPriority(uint8 priority); 33 | uint8 ADC_IRQ_GetPriority(void); 34 | 35 | void ADC_IRQ_Enable(void); 36 | uint8 ADC_IRQ_GetState(void); 37 | void ADC_IRQ_Disable(void); 38 | 39 | void ADC_IRQ_SetPending(void); 40 | void ADC_IRQ_ClearPending(void); 41 | 42 | 43 | /* Interrupt Controller Constants */ 44 | 45 | /* Address of the INTC.VECT[x] register that contains the Address of the ADC_IRQ ISR. */ 46 | #define ADC_IRQ_INTC_VECTOR ((reg32 *) ADC_IRQ__INTC_VECT) 47 | 48 | /* Address of the ADC_IRQ ISR priority. */ 49 | #define ADC_IRQ_INTC_PRIOR ((reg8 *) ADC_IRQ__INTC_PRIOR_REG) 50 | 51 | /* Priority of the ADC_IRQ interrupt. */ 52 | #define ADC_IRQ_INTC_PRIOR_NUMBER ADC_IRQ__INTC_PRIOR_NUM 53 | 54 | /* Address of the INTC.SET_EN[x] byte to bit enable ADC_IRQ interrupt. */ 55 | #define ADC_IRQ_INTC_SET_EN ((reg32 *) ADC_IRQ__INTC_SET_EN_REG) 56 | 57 | /* Address of the INTC.CLR_EN[x] register to bit clear the ADC_IRQ interrupt. */ 58 | #define ADC_IRQ_INTC_CLR_EN ((reg32 *) ADC_IRQ__INTC_CLR_EN_REG) 59 | 60 | /* Address of the INTC.SET_PD[x] register to set the ADC_IRQ interrupt state to pending. */ 61 | #define ADC_IRQ_INTC_SET_PD ((reg32 *) ADC_IRQ__INTC_SET_PD_REG) 62 | 63 | /* Address of the INTC.CLR_PD[x] register to clear the ADC_IRQ interrupt. */ 64 | #define ADC_IRQ_INTC_CLR_PD ((reg32 *) ADC_IRQ__INTC_CLR_PD_REG) 65 | 66 | 67 | #endif /* CY_ISR_ADC_IRQ_H */ 68 | 69 | 70 | /* [] END OF FILE */ 71 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/ADC_Mux.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: ADC_Mux.h 3 | * Version 1.80 4 | * 5 | * Description: 6 | * This file contains the constants and function prototypes for the Analog 7 | * Multiplexer User Module AMux. 8 | * 9 | * Note: 10 | * 11 | ******************************************************************************** 12 | * Copyright 2008-2010, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | ********************************************************************************/ 17 | 18 | #if !defined(CY_AMUX_ADC_Mux_H) 19 | #define CY_AMUX_ADC_Mux_H 20 | 21 | #include "cytypes.h" 22 | #include "cyfitter.h" 23 | #include "cyfitter_cfg.h" 24 | 25 | 26 | /*************************************** 27 | * Function Prototypes 28 | ***************************************/ 29 | 30 | void ADC_Mux_Start(void) ; 31 | #define ADC_Mux_Init() ADC_Mux_Start() 32 | void ADC_Mux_FastSelect(uint8 channel) ; 33 | /* The Stop, Select, Connect, Disconnect and DisconnectAll functions are declared elsewhere */ 34 | /* void ADC_Mux_Stop(void); */ 35 | /* void ADC_Mux_Select(uint8 channel); */ 36 | /* void ADC_Mux_Connect(uint8 channel); */ 37 | /* void ADC_Mux_Disconnect(uint8 channel); */ 38 | /* void ADC_Mux_DisconnectAll(void) */ 39 | 40 | 41 | /*************************************** 42 | * Parameter Constants 43 | ***************************************/ 44 | 45 | #define ADC_Mux_CHANNELS 6u 46 | #define ADC_Mux_MUXTYPE 1 47 | #define ADC_Mux_ATMOSTONE 1 48 | 49 | /*************************************** 50 | * API Constants 51 | ***************************************/ 52 | 53 | #define ADC_Mux_NULL_CHANNEL 0xFFu 54 | #define ADC_Mux_MUX_SINGLE 1 55 | #define ADC_Mux_MUX_DIFF 2 56 | 57 | 58 | /*************************************** 59 | * Conditional Functions 60 | ***************************************/ 61 | 62 | #if ADC_Mux_MUXTYPE == ADC_Mux_MUX_SINGLE 63 | # if !ADC_Mux_ATMOSTONE 64 | # define ADC_Mux_Connect(channel) ADC_Mux_Set(channel) 65 | # endif 66 | # define ADC_Mux_Disconnect(channel) ADC_Mux_Unset(channel) 67 | #else 68 | # if !ADC_Mux_ATMOSTONE 69 | void ADC_Mux_Connect(uint8 channel) ; 70 | # endif 71 | void ADC_Mux_Disconnect(uint8 channel) ; 72 | #endif 73 | 74 | #if ADC_Mux_ATMOSTONE 75 | # define ADC_Mux_Stop() ADC_Mux_DisconnectAll() 76 | # define ADC_Mux_Select(channel) ADC_Mux_FastSelect(channel) 77 | void ADC_Mux_DisconnectAll(void) ; 78 | #else 79 | # define ADC_Mux_Stop() ADC_Mux_Start() 80 | void ADC_Mux_Select(uint8 channel) ; 81 | # define ADC_Mux_DisconnectAll() ADC_Mux_Start() 82 | #endif 83 | 84 | #endif /* CY_AMUX_ADC_Mux_H */ 85 | 86 | 87 | /* [] END OF FILE */ 88 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/A_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: A.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_A_ALIASES_H) /* Pins A_ALIASES_H */ 18 | #define CY_PINS_A_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define A_0 (A__0__PC) 29 | #define A_1 (A__1__PC) 30 | #define A_2 (A__2__PC) 31 | #define A_3 (A__3__PC) 32 | #define A_4 (A__4__PC) 33 | #define A_5 (A__5__PC) 34 | 35 | #endif /* End Pins A_ALIASES_H */ 36 | 37 | /* [] END OF FILE */ 38 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef __arduino_h_ 2 | #define __arduino_h_ 3 | 4 | extern "C" { 5 | #include 6 | } 7 | 8 | #include "Arduino_HW_Interrupt.h" 9 | #include "Arduino_Advanced_IO.h" 10 | #include "Arduino_Analog_In.h" 11 | #include "Arduino_Analog_Out.h" 12 | #include "Arduino_Pins.h" 13 | #include "Arduino_Random.h" 14 | #include "Arduino_Time.h" 15 | #include "Arduino_Tone.h" 16 | #include "Arduino_Serial.h" 17 | #include "UARTClass.h" 18 | #include "Stream.h" 19 | #include "avr/pgmspace.h" 20 | #include "avr/dtostrf.h" 21 | #include "Arduino_Extended_IO.h" 22 | #include "itoa.h" 23 | #include "Wstring.h" 24 | #include 25 | #include "WMath.h" 26 | #include "pins_arduino.h" 27 | 28 | void setup(); 29 | void loop(); 30 | long map(long, long, long, long, long); 31 | long constrain(long, long, long); 32 | long min(long, long); 33 | long max(long, long); 34 | 35 | extern UARTClass Serial; 36 | extern UARTClass Serial1; 37 | 38 | #define boolean bool 39 | #define byte uint8_t 40 | #define PI 3.1415 41 | #define _BV(bit) (1 << (bit)) 42 | #define F_CPU 16000000L 43 | #define Bootloader_SCHEDULE_BTLDR (0x40u) 44 | #define Bootloader_SCHEDULE_BTLDB (0x80u) 45 | #define Bootloader_RESET_SR0_REG (* (reg8 *) CYREG_RESET_SR0) 46 | #define Bootloader_SET_RUN_TYPE(x) (Bootloader_RESET_SR0_REG = (x)) 47 | #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) 48 | #include "WCharacter.h" 49 | #endif 50 | /* [] END OF FILE */ 51 | 52 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Advanced_IO.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | #include 3 | } 4 | 5 | #include 6 | #include "Arduino_Advanced_IO.h" 7 | #include "Arduino.h" 8 | #include "Arduino_Time.h" 9 | 10 | uint32_t pulseIn(uint8_t pin, uint8_t level, uint32_t timeout) 11 | { 12 | pinMode(pin, INPUT); 13 | uint32_t clockStart = micros(); 14 | while (digitalRead(pin) != level) 15 | { 16 | if (micros() - clockStart >= timeout) return 0; 17 | } 18 | clockStart = micros(); 19 | while (digitalRead(pin) == level){}; 20 | return micros() - clockStart; 21 | } 22 | 23 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, \ 24 | uint8_t value) 25 | { 26 | pinMode(dataPin, OUTPUT); 27 | pinMode(clockPin, OUTPUT); 28 | uint8_t i; 29 | if (bitOrder == LSBFIRST) 30 | { 31 | for(i = 0; i<8; i++) 32 | { 33 | if (value>>i & 0x01) digitalWrite(dataPin, HIGH); 34 | else digitalWrite(dataPin, LOW); 35 | digitalWrite(clockPin, digitalRead(clockPin) ^ 0x01); 36 | digitalWrite(clockPin, digitalRead(clockPin) ^ 0x01); 37 | } 38 | } 39 | else 40 | { 41 | for(i = 0; i<8; i++) 42 | { 43 | if (value<> 1; 72 | if (digitalRead(dataPin)) rxByte |= 0x80; 73 | digitalWrite(clockPin, digitalRead(clockPin) ^ 0x01); 74 | digitalWrite(clockPin, digitalRead(clockPin) ^ 0x01); 75 | } 76 | } 77 | return rxByte; 78 | } 79 | /* [] END OF FILE */ 80 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Advanced_IO.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_advanced_io 14 | #define _arduino_advanced_io 15 | 16 | #include 17 | 18 | #define MSBFIRST 0u 19 | #define LSBFIRST 1u 20 | 21 | uint32_t pulseIn(uint8_t pin, uint8_t level, uint32_t timeout); 22 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, \ 23 | uint8_t value); 24 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); 25 | 26 | #endif 27 | /* [] END OF FILE */ 28 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Analog_In.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | extern "C" { 13 | #include 14 | } 15 | 16 | #include 17 | 18 | void initAnalogInput() 19 | { 20 | ADC_Mux_Start(); 21 | ADC_Start(); 22 | } 23 | 24 | uint16_t analogRead(uint8_t pin) 25 | { 26 | if (pin > 19 || pin < 14) return 0; 27 | ADC_Mux_Select(pin-14); 28 | ADC_StartConvert(); 29 | ADC_IsEndConversion(ADC_WAIT_FOR_RESULT); 30 | return ADC_GetResult16(); 31 | } 32 | 33 | /* [] END OF FILE */ 34 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Analog_In.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_analog_in_h 14 | #define _arduino_analog_in_h 15 | 16 | #include 17 | 18 | void initAnalogInput(); 19 | uint16_t analogRead(uint8_t pin); 20 | 21 | #endif 22 | /* [] END OF FILE */ 23 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Analog_Out.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | extern "C" { 13 | #include 14 | } 15 | 16 | #include 17 | #include 18 | 19 | void analogWriteInit() 20 | { 21 | D10_Ctrl_Write(0x00); 22 | D11_Ctrl_Write(0x00); 23 | } 24 | 25 | void analogWrite(uint32_t pin, uint8_t value) 26 | { 27 | switch (pin) 28 | { 29 | case 3: 30 | pin = D3; 31 | PWM_1_WriteCompare1(value); 32 | break; 33 | case 5: 34 | pin = D5; 35 | PWM_1_WriteCompare2(value); 36 | break; 37 | case 6: 38 | pin = D6; 39 | PWM_2_WriteCompare1(value); 40 | break; 41 | case 9: 42 | pin = D9; 43 | PWM_2_WriteCompare2(value); 44 | break; 45 | case 10: 46 | pin = D10; 47 | PWM_3_WriteCompare1(value); 48 | D10_Ctrl_Write(0x00); 49 | break; 50 | case 11: 51 | pin = D11; 52 | PWM_3_WriteCompare2(value); 53 | D11_Ctrl_Write(0x00); 54 | break; 55 | default: 56 | return; 57 | } 58 | 59 | pinMode(pin, PERIPHERAL_OUT); 60 | } 61 | /* [] END OF FILE */ 62 | 63 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Analog_Out.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_analog_out_h 14 | #define _arduino_analog_out_h 15 | 16 | #include 17 | 18 | void analogWrite(uint32_t pin, uint8_t value); 19 | void analogWriteInit(); 20 | 21 | #endif 22 | /* [] END OF FILE */ 23 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Extended_IO.h: -------------------------------------------------------------------------------- 1 | #ifndef __arduino_extended_io_h_ 2 | #define __arduino_extended_io_h_ 3 | 4 | #define NUM_EXTENDED_PINS 40 5 | #include 6 | 7 | enum extendedPinNames { 8 | P0_D0 = P0_0, 9 | P0_D1 = P0_1, 10 | P0_D2 = P0_2, 11 | P0_D3 = P0_3, 12 | P0_D4 = P0_4, 13 | P0_D5 = P0_5, 14 | P0_D6 = P0_6, 15 | P0_D7 = P0_7, 16 | P3_D0 = P3_0, 17 | P3_D1 = P3_1, 18 | P3_D2 = P3_2, 19 | P3_D3 = P3_3, 20 | P3_D4 = P3_4, 21 | P3_D5 = P3_5, 22 | P3_D6 = P3_6, 23 | P3_D7 = P3_7, 24 | P4_D0 = P4_0, 25 | P4_D1 = P4_1, 26 | P4_D2 = P4_2, 27 | P4_D3 = P4_3, 28 | P4_D4 = P4_4, 29 | P4_D5 = P4_5, 30 | P4_D6 = P4_6, 31 | P4_D7 = P4_7, 32 | P5_D0 = P5_0, 33 | P5_D1 = P5_1, 34 | P5_D2 = P5_2, 35 | P5_D3 = P5_3, 36 | P5_D4 = P5_4, 37 | P5_D5 = P5_5, 38 | P5_D6 = P5_6, 39 | P5_D7 = P5_7, 40 | P12_D0 = P12_0, 41 | P12_D1 = P12_1, 42 | P12_D2 = P12_2, 43 | P12_D3 = P12_3, 44 | P1_D7 = P12_4, 45 | P1_D5 = P12_5, 46 | P12_D6 = P12_6, 47 | P12_D7 = P12_7, 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_HW_Interrupt.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | #include 3 | } 4 | 5 | #include "Arduino.h" 6 | #include "Arduino_HW_Interrupt.h" 7 | #include 8 | 9 | void (*INT0Function)(void); 10 | void (*INT1Function)(void); 11 | 12 | #define INT0_MASK 0x04 13 | #define INT1_MASK 0x08 14 | 15 | CY_ISR_PROTO(HW_INT_ISR); 16 | 17 | void attachInterrupt(int interrupt, void (*isr)(), enum HW_INT_MODE mode) 18 | { 19 | uint8_t intStat = *(uint8_t*)CYREG_PICU2_INTSTAT; 20 | if (intStat == 0); 21 | if (interrupt == 0) 22 | { 23 | *(uint8_t*)CYREG_PICU2_INTTYPE2 = mode & 0x03; 24 | INT0Function = isr; 25 | } 26 | else if (interrupt == 1) 27 | { 28 | *(uint8_t*)CYREG_PICU2_INTTYPE3 = mode & 0x03; 29 | INT1Function = isr; 30 | } 31 | HW_INT_StartEx(HW_INT_ISR); 32 | } 33 | 34 | void detachInterrupt(int interrupt) 35 | { 36 | if (interrupt == 0) 37 | { 38 | *(uint8_t*)CYREG_PICU2_INTTYPE2 = DISABLE; 39 | } 40 | else if (interrupt == 1) 41 | { 42 | *(uint8_t*)CYREG_PICU2_INTTYPE3 = DISABLE; 43 | } 44 | } 45 | 46 | CY_ISR(HW_INT_ISR) 47 | { 48 | uint8_t intStat = *(uint8_t*)CYREG_PICU2_INTSTAT; 49 | if ((intStat & INT0_MASK) != 0) 50 | { 51 | INT0Function(); 52 | } 53 | if ((intStat & INT1_MASK) != 0) 54 | { 55 | INT1Function(); 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_HW_Interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef _arduino_hw_int_h_ 2 | #define _arduino_hw_int_h_ 3 | 4 | 5 | enum HW_INT_MODE {DISABLE = 0, 6 | RISING = 1, 7 | FALLING = 2, 8 | CHANGE = 3}; 9 | 10 | void attachInterrupt(int interrupt, void (*isr)(), enum HW_INT_MODE mode); 11 | void detachInterrupt(int interrupt); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long map(long x, long in_min, long in_max, long out_min, long out_max) 4 | { 5 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 6 | } 7 | 8 | long constrain(long x, long a, long b) 9 | { 10 | if (xb) return b; 12 | return x; 13 | } 14 | 15 | long min (long x, long y) 16 | { 17 | return x>y? y: x; 18 | } 19 | 20 | long max(long x, long y) 21 | { 22 | return x>y? y: x; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Pins.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Arduino_Pins.cpp 3 | * Arduino Uno pin compatibility support for the PSoC5LP 4 | * Mike Hord @ SparkFun Electronics 5 | * 14 April 2015 6 | * 7 | * Implements the "standard" Arduino per-pin IO functionality on the PSoC5LP. 8 | * 9 | * Development environment specifics: 10 | * Code developed in PSoC Creator 3.1 11 | * Tested in Arduino IDE 1.6.3 12 | * 13 | * This code is beerware; if you see me (or any other SparkFun employee) at the 14 | * local, and you've found our code helpful, please buy us a round! 15 | * ****************************************************************************/ 16 | 17 | extern "C" { 18 | #include 19 | } 20 | 21 | #include 22 | #include 23 | 24 | // Map the I/O pin number to the actual address of the register as defined by 25 | // the IDE. These constants are mapped to the IDE constants in the header. 26 | uint32_t pinNumberToPointer[NUM_BASE_PINS] = 27 | { D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, 28 | D11, D12, D13, D14, D15, D16, D17, D18, D19}; 29 | 30 | /* Port of the digitalWrite function used by Arduino. Includes a check to 31 | * ensure that the value passed is within the valid range for the aliases 32 | * or for the registers in question. */ 33 | void digitalWrite(uint32_t pin, uint8_t level) 34 | { 35 | if ( pin < NUM_BASE_PINS ) 36 | { 37 | pin = pinNumberToPointer[pin]; 38 | } 39 | // See the TRM for the PSoC5LP for why these numbers were chosen. 40 | else if (pin < 0x40005000 || pin > 0x40005067) 41 | { 42 | return; 43 | } 44 | if (level == HIGH) 45 | { 46 | CyPins_SetPin(pin); 47 | } 48 | else 49 | { 50 | CyPins_ClearPin(pin); 51 | } 52 | } 53 | 54 | // See digitalWrite for explanation. 55 | uint8_t digitalRead(uint32_t pin) 56 | { 57 | if ( pin < NUM_BASE_PINS ) 58 | { 59 | pin = pinNumberToPointer[pin]; 60 | } 61 | else if (pin < 0x40005000 || pin > 0x40005067) 62 | { 63 | return 0; 64 | } 65 | return CyPins_ReadPin(pin); 66 | } 67 | 68 | /* A little more advanced than pinMode for the Arduino, as it needs to handle 69 | * the case where we want to bypass the normal IO circuitry and attach the 70 | * pin to the peripheral bus. */ 71 | void pinMode(uint32_t pin, enum PIN_MODE mode) 72 | { 73 | if ( pin < NUM_BASE_PINS ) 74 | { 75 | pin = pinNumberToPointer[pin]; 76 | } 77 | else if (pin < 0x40005000 || pin > 0x40005067) 78 | { 79 | return; 80 | } 81 | uint8_t registerValue = *(reg8*)(pin); 82 | switch(mode) 83 | { 84 | case OUTPUT: 85 | registerValue &= PIN_DISABLE_BYPASS; 86 | registerValue |= PIN_DM_STRONG; 87 | break; 88 | case INPUT_PULLUP: 89 | registerValue &= PIN_DISABLE_BYPASS; 90 | registerValue |= PIN_DM_RES_UP; 91 | break; 92 | case PERIPHERAL: 93 | registerValue |= PIN_ENABLE_BYPASS; 94 | break; 95 | case PERIPHERAL_IN: 96 | registerValue |= PIN_ENABLE_BYPASS; 97 | registerValue |= PIN_DM_DIG_HIZ; 98 | break; 99 | case PERIPHERAL_OUT: 100 | registerValue |= PIN_ENABLE_BYPASS; 101 | registerValue |= PIN_DM_STRONG; 102 | break; 103 | case PERIPHERAL_OD: 104 | registerValue |= PIN_ENABLE_BYPASS; 105 | registerValue |= PIN_DM_OD_LO; 106 | CyPins_SetPin(pin); 107 | break; 108 | case INPUT: 109 | default: 110 | registerValue &= PIN_DISABLE_BYPASS; 111 | registerValue |= PIN_DM_DIG_HIZ; 112 | break; 113 | } 114 | *(reg8*)(pin) = registerValue; 115 | } 116 | 117 | /* [] END OF FILE */ 118 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Pins.h: -------------------------------------------------------------------------------- 1 | #ifndef _arduino_pins_h 2 | #define _arduino_pins_h 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define NUM_BASE_PINS 20 9 | 10 | #define D0 DA_0 11 | #define D1 DA_1 12 | #define D2 DA_2 13 | #define D3 DA_3 14 | #define D4 DA_4 15 | #define D5 DA_5 16 | #define D6 DA_6 17 | #define D7 DA_7 18 | #define D8 DB_0 19 | #define D9 DB_1 20 | #define D10 DB_2 21 | #define D11 DB_3 22 | #define D12 DB_4 23 | #define D13 DB_5 24 | #define D14 A_0 25 | #define D15 A_1 26 | #define D16 A_2 27 | #define D17 A_3 28 | #define D18 A_4 29 | #define D19 A_5 30 | #define A0 D14 31 | #define A1 D15 32 | #define A2 D16 33 | #define A3 D17 34 | #define A4 D18 35 | #define A5 D19 36 | 37 | #define P1_D2 UserButton_0 38 | 39 | 40 | #define HIGH 1u 41 | #define LOW 0u 42 | 43 | enum PIN_MODE {OUTPUT, INPUT, INPUT_PULLUP, PERIPHERAL, PERIPHERAL_OUT, 44 | PERIPHERAL_IN, PERIPHERAL_OD}; 45 | enum BYPASS_MODE {PIN_ENABLE_BYPASS = 0x80, PIN_DISABLE_BYPASS = 0x7f}; 46 | 47 | extern uint32_t pinNameToPointers[NUM_BASE_PINS]; 48 | 49 | void digitalWrite(uint32_t pin, uint8_t level); 50 | void pinMode(uint32_t pin, enum PIN_MODE mode); 51 | uint8_t digitalRead(uint32_t pin); 52 | 53 | #endif 54 | 55 | /* [] END OF FILE */ 56 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Random.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | extern "C" { 13 | #include 14 | } 15 | 16 | #include 17 | 18 | int32_t random(int32_t min, int32_t max) 19 | { 20 | if (min >= max) 21 | { 22 | return min; 23 | } 24 | int32_t diff = max - min; 25 | int32_t randTemp = PRS_Read() % diff; 26 | return randTemp + min; 27 | } 28 | 29 | void randomSeed(uint32_t seed) 30 | { 31 | if (seed == 0) seed = 1; 32 | PRS_WriteSeed(seed); 33 | } 34 | 35 | /* [] END OF FILE */ 36 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Random.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_random_h 14 | #define _arduino_random_h 15 | 16 | #include 17 | 18 | int32_t random(int32_t min, int32_t max); 19 | void randomSeed(uint32_t seed); 20 | 21 | #endif 22 | /* [] END OF FILE */ 23 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef _Arduino_Serial_h_ 2 | #define _Arduino_Serial_h_ 3 | 4 | #include 5 | #include "UARTClass.h" 6 | 7 | bool enableUSBCDC(); 8 | void USBUART_FunctionAttach(); 9 | void UART_FunctionAttach(); 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Time.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | extern "C" { 14 | #include 15 | } 16 | #include 17 | #include 18 | #include 19 | 20 | static void exitToBootloader(void); 21 | CY_ISR_PROTO(BootloaderReset_ISR); 22 | 23 | void initTimebase(void) 24 | { 25 | Micros_Counter_Start(); 26 | Millis_Counter_Start(); 27 | BootloaderResetTimer_Start(); 28 | BootloaderResetInterrupt_StartEx(BootloaderReset_ISR); 29 | } 30 | 31 | void delay(unsigned int delayms) 32 | { 33 | CyDelay(delayms); 34 | } 35 | 36 | void delayMicroseconds(unsigned int delayus) 37 | { 38 | CyDelayUs(delayus); 39 | } 40 | 41 | CY_ISR(BootloaderReset_ISR) 42 | { 43 | BootloaderResetInterrupt_ClearPending(); 44 | if(USBUART_GetConfiguration() != 0u) 45 | { 46 | if(USBUART_DataIsReady() != 0u) 47 | { 48 | Serial.buffer(); 49 | } 50 | } 51 | if (USBUART_GetDTERate() == 1200) 52 | { 53 | exitToBootloader(); 54 | } 55 | } 56 | 57 | void exitToBootloader(void) 58 | { 59 | Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDR); 60 | CySoftwareReset(); 61 | } 62 | 63 | 64 | /* [] END OF FILE */ 65 | 66 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Time.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_time_h 14 | #define _arduino_time_h 15 | 16 | #include 17 | 18 | #define millis() Millis_Counter_ReadCounter() 19 | #define micros() Micros_Counter_ReadCounter() 20 | 21 | void initTimebase(void); 22 | void delay(unsigned int delayms); 23 | void delayMicroseconds(unsigned int delayus); 24 | 25 | #endif 26 | /* [] END OF FILE */ 27 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Tone.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | extern "C" { 13 | #include 14 | } 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | volatile uint8_t tonePin; // What pin are we playing the note on? 21 | volatile uint32_t toneLength; // How long should the tone last? 22 | volatile uint32_t toneStart; // When did the tone start? 23 | volatile uint32_t toneElapsed; // How long have we been playing our tone? 24 | // When this is equal to toneLength, we 25 | // should stop playing our tone. 26 | 27 | 28 | void initTone(void) 29 | { 30 | Tone_Interrupt_StartEx(ToneInterruptHandler); 31 | tonePin = 255; 32 | } 33 | 34 | void tone(uint8_t pin, uint16_t freq, uint32_t duration) 35 | { 36 | if (tonePin >= 20) return; 37 | tonePin = pin; 38 | pinMode(pin, OUTPUT); 39 | toneLength = duration; 40 | toneStart = millis(); 41 | ToneTimer_Start(); 42 | uint32_t period = 1000000/freq; 43 | ToneTimer_WritePeriod((uint16_t)period); 44 | } 45 | 46 | void noTone(uint8_t pin) 47 | { 48 | if (pin != tonePin) return; 49 | ToneTimer_Stop(); 50 | digitalWrite(tonePin, LOW); 51 | tonePin = 255; 52 | } 53 | 54 | 55 | CY_ISR(ToneInterruptHandler) 56 | { 57 | digitalWrite(tonePin, 0x01 ^ digitalRead(tonePin)); 58 | if (toneLength == 0) return; 59 | toneElapsed = millis() - toneStart; 60 | if (toneLength <= toneElapsed) ToneTimer_Stop(); 61 | tonePin = 255; 62 | } 63 | 64 | /* [] END OF FILE */ 65 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Arduino_Tone.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | #ifndef _arduino_tone_h 14 | #define _arduino_tone_h 15 | 16 | #include 17 | 18 | void initTone(); 19 | void tone(uint8_t pin, uint16_t freq, uint32_t duration); 20 | void noTone(uint8_t pin); 21 | CY_ISR_PROTO(ToneInterruptHandler); 22 | 23 | #endif 24 | /* [] END OF FILE */ 25 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/BootloaderResetInterrupt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: BootloaderResetInterrupt.h 3 | * Version 1.70 4 | * 5 | * Description: 6 | * Provides the function definitions for the Interrupt Controller. 7 | * 8 | * 9 | ******************************************************************************** 10 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 11 | * You may use this file only in accordance with the license, terms, conditions, 12 | * disclaimers, and limitations in the end user license agreement accompanying 13 | * the software package with which this file was provided. 14 | *******************************************************************************/ 15 | #if !defined(CY_ISR_BootloaderResetInterrupt_H) 16 | #define CY_ISR_BootloaderResetInterrupt_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | /* Interrupt Controller API. */ 23 | void BootloaderResetInterrupt_Start(void); 24 | void BootloaderResetInterrupt_StartEx(cyisraddress address); 25 | void BootloaderResetInterrupt_Stop(void); 26 | 27 | CY_ISR_PROTO(BootloaderResetInterrupt_Interrupt); 28 | 29 | void BootloaderResetInterrupt_SetVector(cyisraddress address); 30 | cyisraddress BootloaderResetInterrupt_GetVector(void); 31 | 32 | void BootloaderResetInterrupt_SetPriority(uint8 priority); 33 | uint8 BootloaderResetInterrupt_GetPriority(void); 34 | 35 | void BootloaderResetInterrupt_Enable(void); 36 | uint8 BootloaderResetInterrupt_GetState(void); 37 | void BootloaderResetInterrupt_Disable(void); 38 | 39 | void BootloaderResetInterrupt_SetPending(void); 40 | void BootloaderResetInterrupt_ClearPending(void); 41 | 42 | 43 | /* Interrupt Controller Constants */ 44 | 45 | /* Address of the INTC.VECT[x] register that contains the Address of the BootloaderResetInterrupt ISR. */ 46 | #define BootloaderResetInterrupt_INTC_VECTOR ((reg32 *) BootloaderResetInterrupt__INTC_VECT) 47 | 48 | /* Address of the BootloaderResetInterrupt ISR priority. */ 49 | #define BootloaderResetInterrupt_INTC_PRIOR ((reg8 *) BootloaderResetInterrupt__INTC_PRIOR_REG) 50 | 51 | /* Priority of the BootloaderResetInterrupt interrupt. */ 52 | #define BootloaderResetInterrupt_INTC_PRIOR_NUMBER BootloaderResetInterrupt__INTC_PRIOR_NUM 53 | 54 | /* Address of the INTC.SET_EN[x] byte to bit enable BootloaderResetInterrupt interrupt. */ 55 | #define BootloaderResetInterrupt_INTC_SET_EN ((reg32 *) BootloaderResetInterrupt__INTC_SET_EN_REG) 56 | 57 | /* Address of the INTC.CLR_EN[x] register to bit clear the BootloaderResetInterrupt interrupt. */ 58 | #define BootloaderResetInterrupt_INTC_CLR_EN ((reg32 *) BootloaderResetInterrupt__INTC_CLR_EN_REG) 59 | 60 | /* Address of the INTC.SET_PD[x] register to set the BootloaderResetInterrupt interrupt state to pending. */ 61 | #define BootloaderResetInterrupt_INTC_SET_PD ((reg32 *) BootloaderResetInterrupt__INTC_SET_PD_REG) 62 | 63 | /* Address of the INTC.CLR_PD[x] register to clear the BootloaderResetInterrupt interrupt. */ 64 | #define BootloaderResetInterrupt_INTC_CLR_PD ((reg32 *) BootloaderResetInterrupt__INTC_CLR_PD_REG) 65 | 66 | 67 | #endif /* CY_ISR_BootloaderResetInterrupt_H */ 68 | 69 | 70 | /* [] END OF FILE */ 71 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client : public Stream { 27 | 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Clock_12.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Clock_12.h 3 | * Version 2.20 4 | * 5 | * Description: 6 | * Provides the function and constant definitions for the clock component. 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CLOCK_Clock_12_H) 18 | #define CY_CLOCK_Clock_12_H 19 | 20 | #include 21 | #include 22 | 23 | 24 | /*************************************** 25 | * Conditional Compilation Parameters 26 | ***************************************/ 27 | 28 | /* Check to see if required defines such as CY_PSOC5LP are available */ 29 | /* They are defined starting with cy_boot v3.0 */ 30 | #if !defined (CY_PSOC5LP) 31 | #error Component cy_clock_v2_20 requires cy_boot v3.0 or later 32 | #endif /* (CY_PSOC5LP) */ 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void Clock_12_Start(void) ; 40 | void Clock_12_Stop(void) ; 41 | 42 | #if(CY_PSOC3 || CY_PSOC5LP) 43 | void Clock_12_StopBlock(void) ; 44 | #endif /* (CY_PSOC3 || CY_PSOC5LP) */ 45 | 46 | void Clock_12_StandbyPower(uint8 state) ; 47 | void Clock_12_SetDividerRegister(uint16 clkDivider, uint8 restart) 48 | ; 49 | uint16 Clock_12_GetDividerRegister(void) ; 50 | void Clock_12_SetModeRegister(uint8 modeBitMask) ; 51 | void Clock_12_ClearModeRegister(uint8 modeBitMask) ; 52 | uint8 Clock_12_GetModeRegister(void) ; 53 | void Clock_12_SetSourceRegister(uint8 clkSource) ; 54 | uint8 Clock_12_GetSourceRegister(void) ; 55 | #if defined(Clock_12__CFG3) 56 | void Clock_12_SetPhaseRegister(uint8 clkPhase) ; 57 | uint8 Clock_12_GetPhaseRegister(void) ; 58 | #endif /* defined(Clock_12__CFG3) */ 59 | 60 | #define Clock_12_Enable() Clock_12_Start() 61 | #define Clock_12_Disable() Clock_12_Stop() 62 | #define Clock_12_SetDivider(clkDivider) Clock_12_SetDividerRegister(clkDivider, 1u) 63 | #define Clock_12_SetDividerValue(clkDivider) Clock_12_SetDividerRegister((clkDivider) - 1u, 1u) 64 | #define Clock_12_SetMode(clkMode) Clock_12_SetModeRegister(clkMode) 65 | #define Clock_12_SetSource(clkSource) Clock_12_SetSourceRegister(clkSource) 66 | #if defined(Clock_12__CFG3) 67 | #define Clock_12_SetPhase(clkPhase) Clock_12_SetPhaseRegister(clkPhase) 68 | #define Clock_12_SetPhaseValue(clkPhase) Clock_12_SetPhaseRegister((clkPhase) + 1u) 69 | #endif /* defined(Clock_12__CFG3) */ 70 | 71 | 72 | /*************************************** 73 | * Registers 74 | ***************************************/ 75 | 76 | /* Register to enable or disable the clock */ 77 | #define Clock_12_CLKEN (* (reg8 *) Clock_12__PM_ACT_CFG) 78 | #define Clock_12_CLKEN_PTR ((reg8 *) Clock_12__PM_ACT_CFG) 79 | 80 | /* Register to enable or disable the clock */ 81 | #define Clock_12_CLKSTBY (* (reg8 *) Clock_12__PM_STBY_CFG) 82 | #define Clock_12_CLKSTBY_PTR ((reg8 *) Clock_12__PM_STBY_CFG) 83 | 84 | /* Clock LSB divider configuration register. */ 85 | #define Clock_12_DIV_LSB (* (reg8 *) Clock_12__CFG0) 86 | #define Clock_12_DIV_LSB_PTR ((reg8 *) Clock_12__CFG0) 87 | #define Clock_12_DIV_PTR ((reg16 *) Clock_12__CFG0) 88 | 89 | /* Clock MSB divider configuration register. */ 90 | #define Clock_12_DIV_MSB (* (reg8 *) Clock_12__CFG1) 91 | #define Clock_12_DIV_MSB_PTR ((reg8 *) Clock_12__CFG1) 92 | 93 | /* Mode and source configuration register */ 94 | #define Clock_12_MOD_SRC (* (reg8 *) Clock_12__CFG2) 95 | #define Clock_12_MOD_SRC_PTR ((reg8 *) Clock_12__CFG2) 96 | 97 | #if defined(Clock_12__CFG3) 98 | /* Analog clock phase configuration register */ 99 | #define Clock_12_PHASE (* (reg8 *) Clock_12__CFG3) 100 | #define Clock_12_PHASE_PTR ((reg8 *) Clock_12__CFG3) 101 | #endif /* defined(Clock_12__CFG3) */ 102 | 103 | 104 | /************************************** 105 | * Register Constants 106 | **************************************/ 107 | 108 | /* Power manager register masks */ 109 | #define Clock_12_CLKEN_MASK Clock_12__PM_ACT_MSK 110 | #define Clock_12_CLKSTBY_MASK Clock_12__PM_STBY_MSK 111 | 112 | /* CFG2 field masks */ 113 | #define Clock_12_SRC_SEL_MSK Clock_12__CFG2_SRC_SEL_MASK 114 | #define Clock_12_MODE_MASK (~(Clock_12_SRC_SEL_MSK)) 115 | 116 | #if defined(Clock_12__CFG3) 117 | /* CFG3 phase mask */ 118 | #define Clock_12_PHASE_MASK Clock_12__CFG3_PHASE_DLY_MASK 119 | #endif /* defined(Clock_12__CFG3) */ 120 | 121 | #endif /* CY_CLOCK_Clock_12_H */ 122 | 123 | 124 | /* [] END OF FILE */ 125 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Clock_2.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Clock_2.h 3 | * Version 2.20 4 | * 5 | * Description: 6 | * Provides the function and constant definitions for the clock component. 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CLOCK_Clock_2_H) 18 | #define CY_CLOCK_Clock_2_H 19 | 20 | #include 21 | #include 22 | 23 | 24 | /*************************************** 25 | * Conditional Compilation Parameters 26 | ***************************************/ 27 | 28 | /* Check to see if required defines such as CY_PSOC5LP are available */ 29 | /* They are defined starting with cy_boot v3.0 */ 30 | #if !defined (CY_PSOC5LP) 31 | #error Component cy_clock_v2_20 requires cy_boot v3.0 or later 32 | #endif /* (CY_PSOC5LP) */ 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void Clock_2_Start(void) ; 40 | void Clock_2_Stop(void) ; 41 | 42 | #if(CY_PSOC3 || CY_PSOC5LP) 43 | void Clock_2_StopBlock(void) ; 44 | #endif /* (CY_PSOC3 || CY_PSOC5LP) */ 45 | 46 | void Clock_2_StandbyPower(uint8 state) ; 47 | void Clock_2_SetDividerRegister(uint16 clkDivider, uint8 restart) 48 | ; 49 | uint16 Clock_2_GetDividerRegister(void) ; 50 | void Clock_2_SetModeRegister(uint8 modeBitMask) ; 51 | void Clock_2_ClearModeRegister(uint8 modeBitMask) ; 52 | uint8 Clock_2_GetModeRegister(void) ; 53 | void Clock_2_SetSourceRegister(uint8 clkSource) ; 54 | uint8 Clock_2_GetSourceRegister(void) ; 55 | #if defined(Clock_2__CFG3) 56 | void Clock_2_SetPhaseRegister(uint8 clkPhase) ; 57 | uint8 Clock_2_GetPhaseRegister(void) ; 58 | #endif /* defined(Clock_2__CFG3) */ 59 | 60 | #define Clock_2_Enable() Clock_2_Start() 61 | #define Clock_2_Disable() Clock_2_Stop() 62 | #define Clock_2_SetDivider(clkDivider) Clock_2_SetDividerRegister(clkDivider, 1u) 63 | #define Clock_2_SetDividerValue(clkDivider) Clock_2_SetDividerRegister((clkDivider) - 1u, 1u) 64 | #define Clock_2_SetMode(clkMode) Clock_2_SetModeRegister(clkMode) 65 | #define Clock_2_SetSource(clkSource) Clock_2_SetSourceRegister(clkSource) 66 | #if defined(Clock_2__CFG3) 67 | #define Clock_2_SetPhase(clkPhase) Clock_2_SetPhaseRegister(clkPhase) 68 | #define Clock_2_SetPhaseValue(clkPhase) Clock_2_SetPhaseRegister((clkPhase) + 1u) 69 | #endif /* defined(Clock_2__CFG3) */ 70 | 71 | 72 | /*************************************** 73 | * Registers 74 | ***************************************/ 75 | 76 | /* Register to enable or disable the clock */ 77 | #define Clock_2_CLKEN (* (reg8 *) Clock_2__PM_ACT_CFG) 78 | #define Clock_2_CLKEN_PTR ((reg8 *) Clock_2__PM_ACT_CFG) 79 | 80 | /* Register to enable or disable the clock */ 81 | #define Clock_2_CLKSTBY (* (reg8 *) Clock_2__PM_STBY_CFG) 82 | #define Clock_2_CLKSTBY_PTR ((reg8 *) Clock_2__PM_STBY_CFG) 83 | 84 | /* Clock LSB divider configuration register. */ 85 | #define Clock_2_DIV_LSB (* (reg8 *) Clock_2__CFG0) 86 | #define Clock_2_DIV_LSB_PTR ((reg8 *) Clock_2__CFG0) 87 | #define Clock_2_DIV_PTR ((reg16 *) Clock_2__CFG0) 88 | 89 | /* Clock MSB divider configuration register. */ 90 | #define Clock_2_DIV_MSB (* (reg8 *) Clock_2__CFG1) 91 | #define Clock_2_DIV_MSB_PTR ((reg8 *) Clock_2__CFG1) 92 | 93 | /* Mode and source configuration register */ 94 | #define Clock_2_MOD_SRC (* (reg8 *) Clock_2__CFG2) 95 | #define Clock_2_MOD_SRC_PTR ((reg8 *) Clock_2__CFG2) 96 | 97 | #if defined(Clock_2__CFG3) 98 | /* Analog clock phase configuration register */ 99 | #define Clock_2_PHASE (* (reg8 *) Clock_2__CFG3) 100 | #define Clock_2_PHASE_PTR ((reg8 *) Clock_2__CFG3) 101 | #endif /* defined(Clock_2__CFG3) */ 102 | 103 | 104 | /************************************** 105 | * Register Constants 106 | **************************************/ 107 | 108 | /* Power manager register masks */ 109 | #define Clock_2_CLKEN_MASK Clock_2__PM_ACT_MSK 110 | #define Clock_2_CLKSTBY_MASK Clock_2__PM_STBY_MSK 111 | 112 | /* CFG2 field masks */ 113 | #define Clock_2_SRC_SEL_MSK Clock_2__CFG2_SRC_SEL_MASK 114 | #define Clock_2_MODE_MASK (~(Clock_2_SRC_SEL_MSK)) 115 | 116 | #if defined(Clock_2__CFG3) 117 | /* CFG3 phase mask */ 118 | #define Clock_2_PHASE_MASK Clock_2__CFG3_PHASE_DLY_MASK 119 | #endif /* defined(Clock_2__CFG3) */ 120 | 121 | #endif /* CY_CLOCK_Clock_2_H */ 122 | 123 | 124 | /* [] END OF FILE */ 125 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Clock_3.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Clock_3.h 3 | * Version 2.20 4 | * 5 | * Description: 6 | * Provides the function and constant definitions for the clock component. 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CLOCK_Clock_3_H) 18 | #define CY_CLOCK_Clock_3_H 19 | 20 | #include 21 | #include 22 | 23 | 24 | /*************************************** 25 | * Conditional Compilation Parameters 26 | ***************************************/ 27 | 28 | /* Check to see if required defines such as CY_PSOC5LP are available */ 29 | /* They are defined starting with cy_boot v3.0 */ 30 | #if !defined (CY_PSOC5LP) 31 | #error Component cy_clock_v2_20 requires cy_boot v3.0 or later 32 | #endif /* (CY_PSOC5LP) */ 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void Clock_3_Start(void) ; 40 | void Clock_3_Stop(void) ; 41 | 42 | #if(CY_PSOC3 || CY_PSOC5LP) 43 | void Clock_3_StopBlock(void) ; 44 | #endif /* (CY_PSOC3 || CY_PSOC5LP) */ 45 | 46 | void Clock_3_StandbyPower(uint8 state) ; 47 | void Clock_3_SetDividerRegister(uint16 clkDivider, uint8 restart) 48 | ; 49 | uint16 Clock_3_GetDividerRegister(void) ; 50 | void Clock_3_SetModeRegister(uint8 modeBitMask) ; 51 | void Clock_3_ClearModeRegister(uint8 modeBitMask) ; 52 | uint8 Clock_3_GetModeRegister(void) ; 53 | void Clock_3_SetSourceRegister(uint8 clkSource) ; 54 | uint8 Clock_3_GetSourceRegister(void) ; 55 | #if defined(Clock_3__CFG3) 56 | void Clock_3_SetPhaseRegister(uint8 clkPhase) ; 57 | uint8 Clock_3_GetPhaseRegister(void) ; 58 | #endif /* defined(Clock_3__CFG3) */ 59 | 60 | #define Clock_3_Enable() Clock_3_Start() 61 | #define Clock_3_Disable() Clock_3_Stop() 62 | #define Clock_3_SetDivider(clkDivider) Clock_3_SetDividerRegister(clkDivider, 1u) 63 | #define Clock_3_SetDividerValue(clkDivider) Clock_3_SetDividerRegister((clkDivider) - 1u, 1u) 64 | #define Clock_3_SetMode(clkMode) Clock_3_SetModeRegister(clkMode) 65 | #define Clock_3_SetSource(clkSource) Clock_3_SetSourceRegister(clkSource) 66 | #if defined(Clock_3__CFG3) 67 | #define Clock_3_SetPhase(clkPhase) Clock_3_SetPhaseRegister(clkPhase) 68 | #define Clock_3_SetPhaseValue(clkPhase) Clock_3_SetPhaseRegister((clkPhase) + 1u) 69 | #endif /* defined(Clock_3__CFG3) */ 70 | 71 | 72 | /*************************************** 73 | * Registers 74 | ***************************************/ 75 | 76 | /* Register to enable or disable the clock */ 77 | #define Clock_3_CLKEN (* (reg8 *) Clock_3__PM_ACT_CFG) 78 | #define Clock_3_CLKEN_PTR ((reg8 *) Clock_3__PM_ACT_CFG) 79 | 80 | /* Register to enable or disable the clock */ 81 | #define Clock_3_CLKSTBY (* (reg8 *) Clock_3__PM_STBY_CFG) 82 | #define Clock_3_CLKSTBY_PTR ((reg8 *) Clock_3__PM_STBY_CFG) 83 | 84 | /* Clock LSB divider configuration register. */ 85 | #define Clock_3_DIV_LSB (* (reg8 *) Clock_3__CFG0) 86 | #define Clock_3_DIV_LSB_PTR ((reg8 *) Clock_3__CFG0) 87 | #define Clock_3_DIV_PTR ((reg16 *) Clock_3__CFG0) 88 | 89 | /* Clock MSB divider configuration register. */ 90 | #define Clock_3_DIV_MSB (* (reg8 *) Clock_3__CFG1) 91 | #define Clock_3_DIV_MSB_PTR ((reg8 *) Clock_3__CFG1) 92 | 93 | /* Mode and source configuration register */ 94 | #define Clock_3_MOD_SRC (* (reg8 *) Clock_3__CFG2) 95 | #define Clock_3_MOD_SRC_PTR ((reg8 *) Clock_3__CFG2) 96 | 97 | #if defined(Clock_3__CFG3) 98 | /* Analog clock phase configuration register */ 99 | #define Clock_3_PHASE (* (reg8 *) Clock_3__CFG3) 100 | #define Clock_3_PHASE_PTR ((reg8 *) Clock_3__CFG3) 101 | #endif /* defined(Clock_3__CFG3) */ 102 | 103 | 104 | /************************************** 105 | * Register Constants 106 | **************************************/ 107 | 108 | /* Power manager register masks */ 109 | #define Clock_3_CLKEN_MASK Clock_3__PM_ACT_MSK 110 | #define Clock_3_CLKSTBY_MASK Clock_3__PM_STBY_MSK 111 | 112 | /* CFG2 field masks */ 113 | #define Clock_3_SRC_SEL_MSK Clock_3__CFG2_SRC_SEL_MASK 114 | #define Clock_3_MODE_MASK (~(Clock_3_SRC_SEL_MSK)) 115 | 116 | #if defined(Clock_3__CFG3) 117 | /* CFG3 phase mask */ 118 | #define Clock_3_PHASE_MASK Clock_3__CFG3_PHASE_DLY_MASK 119 | #endif /* defined(Clock_3__CFG3) */ 120 | 121 | #endif /* CY_CLOCK_Clock_3_H */ 122 | 123 | 124 | /* [] END OF FILE */ 125 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Clock_5.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Clock_5.h 3 | * Version 2.20 4 | * 5 | * Description: 6 | * Provides the function and constant definitions for the clock component. 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2012, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CLOCK_Clock_5_H) 18 | #define CY_CLOCK_Clock_5_H 19 | 20 | #include 21 | #include 22 | 23 | 24 | /*************************************** 25 | * Conditional Compilation Parameters 26 | ***************************************/ 27 | 28 | /* Check to see if required defines such as CY_PSOC5LP are available */ 29 | /* They are defined starting with cy_boot v3.0 */ 30 | #if !defined (CY_PSOC5LP) 31 | #error Component cy_clock_v2_20 requires cy_boot v3.0 or later 32 | #endif /* (CY_PSOC5LP) */ 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void Clock_5_Start(void) ; 40 | void Clock_5_Stop(void) ; 41 | 42 | #if(CY_PSOC3 || CY_PSOC5LP) 43 | void Clock_5_StopBlock(void) ; 44 | #endif /* (CY_PSOC3 || CY_PSOC5LP) */ 45 | 46 | void Clock_5_StandbyPower(uint8 state) ; 47 | void Clock_5_SetDividerRegister(uint16 clkDivider, uint8 restart) 48 | ; 49 | uint16 Clock_5_GetDividerRegister(void) ; 50 | void Clock_5_SetModeRegister(uint8 modeBitMask) ; 51 | void Clock_5_ClearModeRegister(uint8 modeBitMask) ; 52 | uint8 Clock_5_GetModeRegister(void) ; 53 | void Clock_5_SetSourceRegister(uint8 clkSource) ; 54 | uint8 Clock_5_GetSourceRegister(void) ; 55 | #if defined(Clock_5__CFG3) 56 | void Clock_5_SetPhaseRegister(uint8 clkPhase) ; 57 | uint8 Clock_5_GetPhaseRegister(void) ; 58 | #endif /* defined(Clock_5__CFG3) */ 59 | 60 | #define Clock_5_Enable() Clock_5_Start() 61 | #define Clock_5_Disable() Clock_5_Stop() 62 | #define Clock_5_SetDivider(clkDivider) Clock_5_SetDividerRegister(clkDivider, 1u) 63 | #define Clock_5_SetDividerValue(clkDivider) Clock_5_SetDividerRegister((clkDivider) - 1u, 1u) 64 | #define Clock_5_SetMode(clkMode) Clock_5_SetModeRegister(clkMode) 65 | #define Clock_5_SetSource(clkSource) Clock_5_SetSourceRegister(clkSource) 66 | #if defined(Clock_5__CFG3) 67 | #define Clock_5_SetPhase(clkPhase) Clock_5_SetPhaseRegister(clkPhase) 68 | #define Clock_5_SetPhaseValue(clkPhase) Clock_5_SetPhaseRegister((clkPhase) + 1u) 69 | #endif /* defined(Clock_5__CFG3) */ 70 | 71 | 72 | /*************************************** 73 | * Registers 74 | ***************************************/ 75 | 76 | /* Register to enable or disable the clock */ 77 | #define Clock_5_CLKEN (* (reg8 *) Clock_5__PM_ACT_CFG) 78 | #define Clock_5_CLKEN_PTR ((reg8 *) Clock_5__PM_ACT_CFG) 79 | 80 | /* Register to enable or disable the clock */ 81 | #define Clock_5_CLKSTBY (* (reg8 *) Clock_5__PM_STBY_CFG) 82 | #define Clock_5_CLKSTBY_PTR ((reg8 *) Clock_5__PM_STBY_CFG) 83 | 84 | /* Clock LSB divider configuration register. */ 85 | #define Clock_5_DIV_LSB (* (reg8 *) Clock_5__CFG0) 86 | #define Clock_5_DIV_LSB_PTR ((reg8 *) Clock_5__CFG0) 87 | #define Clock_5_DIV_PTR ((reg16 *) Clock_5__CFG0) 88 | 89 | /* Clock MSB divider configuration register. */ 90 | #define Clock_5_DIV_MSB (* (reg8 *) Clock_5__CFG1) 91 | #define Clock_5_DIV_MSB_PTR ((reg8 *) Clock_5__CFG1) 92 | 93 | /* Mode and source configuration register */ 94 | #define Clock_5_MOD_SRC (* (reg8 *) Clock_5__CFG2) 95 | #define Clock_5_MOD_SRC_PTR ((reg8 *) Clock_5__CFG2) 96 | 97 | #if defined(Clock_5__CFG3) 98 | /* Analog clock phase configuration register */ 99 | #define Clock_5_PHASE (* (reg8 *) Clock_5__CFG3) 100 | #define Clock_5_PHASE_PTR ((reg8 *) Clock_5__CFG3) 101 | #endif /* defined(Clock_5__CFG3) */ 102 | 103 | 104 | /************************************** 105 | * Register Constants 106 | **************************************/ 107 | 108 | /* Power manager register masks */ 109 | #define Clock_5_CLKEN_MASK Clock_5__PM_ACT_MSK 110 | #define Clock_5_CLKSTBY_MASK Clock_5__PM_STBY_MSK 111 | 112 | /* CFG2 field masks */ 113 | #define Clock_5_SRC_SEL_MSK Clock_5__CFG2_SRC_SEL_MASK 114 | #define Clock_5_MODE_MASK (~(Clock_5_SRC_SEL_MSK)) 115 | 116 | #if defined(Clock_5__CFG3) 117 | /* CFG3 phase mask */ 118 | #define Clock_5_PHASE_MASK Clock_5__CFG3_PHASE_DLY_MASK 119 | #endif /* defined(Clock_5__CFG3) */ 120 | 121 | #endif /* CY_CLOCK_Clock_5_H */ 122 | 123 | 124 | /* [] END OF FILE */ 125 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/D10_Ctrl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: D10_Ctrl.h 3 | * Version 1.80 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CONTROL_REG_D10_Ctrl_H) /* CY_CONTROL_REG_D10_Ctrl_H */ 18 | #define CY_CONTROL_REG_D10_Ctrl_H 19 | 20 | #include "cytypes.h" 21 | 22 | 23 | /*************************************** 24 | * Data Struct Definitions 25 | ***************************************/ 26 | 27 | /* Sleep Mode API Support */ 28 | typedef struct 29 | { 30 | uint8 controlState; 31 | 32 | } D10_Ctrl_BACKUP_STRUCT; 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void D10_Ctrl_Write(uint8 control) ; 40 | uint8 D10_Ctrl_Read(void) ; 41 | 42 | void D10_Ctrl_SaveConfig(void) ; 43 | void D10_Ctrl_RestoreConfig(void) ; 44 | void D10_Ctrl_Sleep(void) ; 45 | void D10_Ctrl_Wakeup(void) ; 46 | 47 | 48 | /*************************************** 49 | * Registers 50 | ***************************************/ 51 | 52 | /* Control Register */ 53 | #define D10_Ctrl_Control (* (reg8 *) D10_Ctrl_Sync_ctrl_reg__CONTROL_REG ) 54 | #define D10_Ctrl_Control_PTR ( (reg8 *) D10_Ctrl_Sync_ctrl_reg__CONTROL_REG ) 55 | 56 | #endif /* End CY_CONTROL_REG_D10_Ctrl_H */ 57 | 58 | 59 | /* [] END OF FILE */ 60 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/D11_Ctrl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: D11_Ctrl.h 3 | * Version 1.80 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CONTROL_REG_D11_Ctrl_H) /* CY_CONTROL_REG_D11_Ctrl_H */ 18 | #define CY_CONTROL_REG_D11_Ctrl_H 19 | 20 | #include "cytypes.h" 21 | 22 | 23 | /*************************************** 24 | * Data Struct Definitions 25 | ***************************************/ 26 | 27 | /* Sleep Mode API Support */ 28 | typedef struct 29 | { 30 | uint8 controlState; 31 | 32 | } D11_Ctrl_BACKUP_STRUCT; 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void D11_Ctrl_Write(uint8 control) ; 40 | uint8 D11_Ctrl_Read(void) ; 41 | 42 | void D11_Ctrl_SaveConfig(void) ; 43 | void D11_Ctrl_RestoreConfig(void) ; 44 | void D11_Ctrl_Sleep(void) ; 45 | void D11_Ctrl_Wakeup(void) ; 46 | 47 | 48 | /*************************************** 49 | * Registers 50 | ***************************************/ 51 | 52 | /* Control Register */ 53 | #define D11_Ctrl_Control (* (reg8 *) D11_Ctrl_Sync_ctrl_reg__CONTROL_REG ) 54 | #define D11_Ctrl_Control_PTR ( (reg8 *) D11_Ctrl_Sync_ctrl_reg__CONTROL_REG ) 55 | 56 | #endif /* End CY_CONTROL_REG_D11_Ctrl_H */ 57 | 58 | 59 | /* [] END OF FILE */ 60 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/DA_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: DA.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_DA_ALIASES_H) /* Pins DA_ALIASES_H */ 18 | #define CY_PINS_DA_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define DA_0 (DA__0__PC) 29 | #define DA_1 (DA__1__PC) 30 | #define DA_2 (DA__2__PC) 31 | #define DA_3 (DA__3__PC) 32 | #define DA_4 (DA__4__PC) 33 | #define DA_5 (DA__5__PC) 34 | #define DA_6 (DA__6__PC) 35 | #define DA_7 (DA__7__PC) 36 | 37 | #endif /* End Pins DA_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/DB_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: DB.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_DB_ALIASES_H) /* Pins DB_ALIASES_H */ 18 | #define CY_PINS_DB_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define DB_0 (DB__0__PC) 29 | #define DB_1 (DB__1__PC) 30 | #define DB_2 (DB__2__PC) 31 | #define DB_3 (DB__3__PC) 32 | #define DB_4 (DB__4__PC) 33 | #define DB_5 (DB__5__PC) 34 | 35 | #endif /* End Pins DB_ALIASES_H */ 36 | 37 | /* [] END OF FILE */ 38 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/HW_INT.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: HW_INT.h 3 | * Version 1.70 4 | * 5 | * Description: 6 | * Provides the function definitions for the Interrupt Controller. 7 | * 8 | * 9 | ******************************************************************************** 10 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 11 | * You may use this file only in accordance with the license, terms, conditions, 12 | * disclaimers, and limitations in the end user license agreement accompanying 13 | * the software package with which this file was provided. 14 | *******************************************************************************/ 15 | #if !defined(CY_ISR_HW_INT_H) 16 | #define CY_ISR_HW_INT_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | /* Interrupt Controller API. */ 23 | void HW_INT_Start(void); 24 | void HW_INT_StartEx(cyisraddress address); 25 | void HW_INT_Stop(void); 26 | 27 | CY_ISR_PROTO(HW_INT_Interrupt); 28 | 29 | void HW_INT_SetVector(cyisraddress address); 30 | cyisraddress HW_INT_GetVector(void); 31 | 32 | void HW_INT_SetPriority(uint8 priority); 33 | uint8 HW_INT_GetPriority(void); 34 | 35 | void HW_INT_Enable(void); 36 | uint8 HW_INT_GetState(void); 37 | void HW_INT_Disable(void); 38 | 39 | void HW_INT_SetPending(void); 40 | void HW_INT_ClearPending(void); 41 | 42 | 43 | /* Interrupt Controller Constants */ 44 | 45 | /* Address of the INTC.VECT[x] register that contains the Address of the HW_INT ISR. */ 46 | #define HW_INT_INTC_VECTOR ((reg32 *) HW_INT__INTC_VECT) 47 | 48 | /* Address of the HW_INT ISR priority. */ 49 | #define HW_INT_INTC_PRIOR ((reg8 *) HW_INT__INTC_PRIOR_REG) 50 | 51 | /* Priority of the HW_INT interrupt. */ 52 | #define HW_INT_INTC_PRIOR_NUMBER HW_INT__INTC_PRIOR_NUM 53 | 54 | /* Address of the INTC.SET_EN[x] byte to bit enable HW_INT interrupt. */ 55 | #define HW_INT_INTC_SET_EN ((reg32 *) HW_INT__INTC_SET_EN_REG) 56 | 57 | /* Address of the INTC.CLR_EN[x] register to bit clear the HW_INT interrupt. */ 58 | #define HW_INT_INTC_CLR_EN ((reg32 *) HW_INT__INTC_CLR_EN_REG) 59 | 60 | /* Address of the INTC.SET_PD[x] register to set the HW_INT interrupt state to pending. */ 61 | #define HW_INT_INTC_SET_PD ((reg32 *) HW_INT__INTC_SET_PD_REG) 62 | 63 | /* Address of the INTC.CLR_PD[x] register to clear the HW_INT interrupt. */ 64 | #define HW_INT_INTC_CLR_PD ((reg32 *) HW_INT__INTC_CLR_PD_REG) 65 | 66 | 67 | #endif /* CY_ISR_HW_INT_H */ 68 | 69 | 70 | /* [] END OF FILE */ 71 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef HardwareSerial_h 20 | #define HardwareSerial_h 21 | 22 | #include 23 | 24 | #include "Stream.h" 25 | 26 | class HardwareSerial : public Stream 27 | { 28 | public: 29 | HardwareSerial(){} 30 | ~HardwareSerial(){} 31 | virtual void begin(unsigned long) = 0; 32 | virtual void end() = 0; 33 | virtual int available(void) = 0; 34 | virtual int peek(void) = 0; 35 | virtual int read(void) = 0; 36 | virtual void flush(void) = 0; 37 | virtual size_t write(uint8_t) = 0; 38 | using Print::write; // pull in write(str) and write(buf, size) from Print 39 | virtual operator bool() = 0; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/I2C_Enable.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: I2C_Enable.h 3 | * Version 1.80 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CONTROL_REG_I2C_Enable_H) /* CY_CONTROL_REG_I2C_Enable_H */ 18 | #define CY_CONTROL_REG_I2C_Enable_H 19 | 20 | #include "cytypes.h" 21 | 22 | 23 | /*************************************** 24 | * Data Struct Definitions 25 | ***************************************/ 26 | 27 | /* Sleep Mode API Support */ 28 | typedef struct 29 | { 30 | uint8 controlState; 31 | 32 | } I2C_Enable_BACKUP_STRUCT; 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void I2C_Enable_Write(uint8 control) ; 40 | uint8 I2C_Enable_Read(void) ; 41 | 42 | void I2C_Enable_SaveConfig(void) ; 43 | void I2C_Enable_RestoreConfig(void) ; 44 | void I2C_Enable_Sleep(void) ; 45 | void I2C_Enable_Wakeup(void) ; 46 | 47 | 48 | /*************************************** 49 | * Registers 50 | ***************************************/ 51 | 52 | /* Control Register */ 53 | #define I2C_Enable_Control (* (reg8 *) I2C_Enable_Sync_ctrl_reg__CONTROL_REG ) 54 | #define I2C_Enable_Control_PTR ( (reg8 *) I2C_Enable_Sync_ctrl_reg__CONTROL_REG ) 55 | 56 | #endif /* End CY_CONTROL_REG_I2C_Enable_H */ 57 | 58 | 59 | /* [] END OF FILE */ 60 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/I2C_PVT.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: .h 3 | * Version 3.50 4 | * 5 | * Description: 6 | * This file provides private constants and parameter values for the I2C 7 | * component. 8 | * 9 | * Note: 10 | * 11 | ******************************************************************************** 12 | * Copyright 2012-2015, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | *******************************************************************************/ 17 | 18 | #if !defined(CY_I2C_PVT_I2C_H) 19 | #define CY_I2C_PVT_I2C_H 20 | 21 | #include "I2C.h" 22 | 23 | #define I2C_TIMEOUT_ENABLED_INC (0u) 24 | #if (0u != I2C_TIMEOUT_ENABLED_INC) 25 | #include "I2C_TMOUT.h" 26 | #endif /* (0u != I2C_TIMEOUT_ENABLED_INC) */ 27 | 28 | 29 | /********************************** 30 | * Variables with external linkage 31 | **********************************/ 32 | 33 | extern I2C_BACKUP_STRUCT I2C_backup; 34 | 35 | extern volatile uint8 I2C_state; /* Current state of I2C FSM */ 36 | 37 | /* Master variables */ 38 | #if (I2C_MODE_MASTER_ENABLED) 39 | extern volatile uint8 I2C_mstrStatus; /* Master Status byte */ 40 | extern volatile uint8 I2C_mstrControl; /* Master Control byte */ 41 | 42 | /* Transmit buffer variables */ 43 | extern volatile uint8 * I2C_mstrRdBufPtr; /* Pointer to Master Read buffer */ 44 | extern volatile uint8 I2C_mstrRdBufSize; /* Master Read buffer size */ 45 | extern volatile uint8 I2C_mstrRdBufIndex; /* Master Read buffer Index */ 46 | 47 | /* Receive buffer variables */ 48 | extern volatile uint8 * I2C_mstrWrBufPtr; /* Pointer to Master Write buffer */ 49 | extern volatile uint8 I2C_mstrWrBufSize; /* Master Write buffer size */ 50 | extern volatile uint8 I2C_mstrWrBufIndex; /* Master Write buffer Index */ 51 | 52 | #endif /* (I2C_MODE_MASTER_ENABLED) */ 53 | 54 | /* Slave variables */ 55 | #if (I2C_MODE_SLAVE_ENABLED) 56 | extern volatile uint8 I2C_slStatus; /* Slave Status */ 57 | 58 | /* Transmit buffer variables */ 59 | extern volatile uint8 * I2C_slRdBufPtr; /* Pointer to Transmit buffer */ 60 | extern volatile uint8 I2C_slRdBufSize; /* Slave Transmit buffer size */ 61 | extern volatile uint8 I2C_slRdBufIndex; /* Slave Transmit buffer Index */ 62 | 63 | /* Receive buffer variables */ 64 | extern volatile uint8 * I2C_slWrBufPtr; /* Pointer to Receive buffer */ 65 | extern volatile uint8 I2C_slWrBufSize; /* Slave Receive buffer size */ 66 | extern volatile uint8 I2C_slWrBufIndex; /* Slave Receive buffer Index */ 67 | 68 | #if (I2C_SW_ADRR_DECODE) 69 | extern volatile uint8 I2C_slAddress; /* Software address variable */ 70 | #endif /* (I2C_SW_ADRR_DECODE) */ 71 | 72 | #endif /* (I2C_MODE_SLAVE_ENABLED) */ 73 | 74 | #if ((I2C_FF_IMPLEMENTED) && (I2C_WAKEUP_ENABLED)) 75 | extern volatile uint8 I2C_wakeupSource; 76 | #endif /* ((I2C_FF_IMPLEMENTED) && (I2C_WAKEUP_ENABLED)) */ 77 | 78 | 79 | #endif /* CY_I2C_PVT_I2C_H */ 80 | 81 | 82 | /* [] END OF FILE */ 83 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/IPAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.cpp - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | IPAddress::IPAddress() 24 | { 25 | _address.dword = 0; 26 | } 27 | 28 | IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) 29 | { 30 | _address.bytes[0] = first_octet; 31 | _address.bytes[1] = second_octet; 32 | _address.bytes[2] = third_octet; 33 | _address.bytes[3] = fourth_octet; 34 | } 35 | 36 | IPAddress::IPAddress(uint32_t address) 37 | { 38 | _address.dword = address; 39 | } 40 | 41 | IPAddress::IPAddress(const uint8_t *address) 42 | { 43 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 44 | } 45 | 46 | IPAddress& IPAddress::operator=(const uint8_t *address) 47 | { 48 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 49 | return *this; 50 | } 51 | 52 | IPAddress& IPAddress::operator=(uint32_t address) 53 | { 54 | _address.dword = address; 55 | return *this; 56 | } 57 | 58 | bool IPAddress::operator==(const uint8_t* addr) const 59 | { 60 | return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; 61 | } 62 | 63 | size_t IPAddress::printTo(Print& p) const 64 | { 65 | size_t n = 0; 66 | for (int i =0; i < 3; i++) 67 | { 68 | n += p.print(_address.bytes[i], DEC); 69 | n += p.print('.'); 70 | } 71 | n += p.print(_address.bytes[3], DEC); 72 | return n; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/IPAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.h - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef IPAddress_h 21 | #define IPAddress_h 22 | 23 | #include 24 | #include 25 | 26 | // A class to make it easier to handle and pass around IP addresses 27 | 28 | class IPAddress : public Printable { 29 | private: 30 | union { 31 | uint8_t bytes[4]; // IPv4 address 32 | uint32_t dword; 33 | } _address; 34 | 35 | // Access the raw byte array containing the address. Because this returns a pointer 36 | // to the internal structure rather than a copy of the address this function should only 37 | // be used when you know that the usage of the returned uint8_t* will be transient and not 38 | // stored. 39 | uint8_t* raw_address() { return _address.bytes; }; 40 | 41 | public: 42 | // Constructors 43 | IPAddress(); 44 | IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); 45 | IPAddress(uint32_t address); 46 | IPAddress(const uint8_t *address); 47 | 48 | // Overloaded cast operator to allow IPAddress objects to be used where a pointer 49 | // to a four-byte uint8_t array is expected 50 | operator uint32_t() const { return _address.dword; }; 51 | bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; }; 52 | bool operator==(const uint8_t* addr) const; 53 | 54 | // Overloaded index operator to allow getting and setting individual octets of the address 55 | uint8_t operator[](int index) const { return _address.bytes[index]; }; 56 | uint8_t& operator[](int index) { return _address.bytes[index]; }; 57 | 58 | // Overloaded copy operators to allow initialisation of IPAddress objects from other types 59 | IPAddress& operator=(const uint8_t *address); 60 | IPAddress& operator=(uint32_t address); 61 | 62 | virtual size_t printTo(Print& p) const; 63 | 64 | friend class EthernetClass; 65 | friend class UDP; 66 | friend class Client; 67 | friend class Server; 68 | friend class DhcpClass; 69 | friend class DNSClient; 70 | }; 71 | 72 | const IPAddress INADDR_NONE(0,0,0,0); 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/P0_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: P0.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_P0_ALIASES_H) /* Pins P0_ALIASES_H */ 18 | #define CY_PINS_P0_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define P0_0 (P0__0__PC) 29 | #define P0_1 (P0__1__PC) 30 | #define P0_2 (P0__2__PC) 31 | #define P0_3 (P0__3__PC) 32 | #define P0_4 (P0__4__PC) 33 | #define P0_5 (P0__5__PC) 34 | #define P0_6 (P0__6__PC) 35 | #define P0_7 (P0__7__PC) 36 | 37 | #endif /* End Pins P0_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/P12_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: P12.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_P12_ALIASES_H) /* Pins P12_ALIASES_H */ 18 | #define CY_PINS_P12_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define P12_0 (P12__0__PC) 29 | #define P12_1 (P12__1__PC) 30 | #define P12_2 (P12__2__PC) 31 | #define P12_3 (P12__3__PC) 32 | #define P12_4 (P12__4__PC) 33 | #define P12_5 (P12__5__PC) 34 | #define P12_6 (P12__6__PC) 35 | #define P12_7 (P12__7__PC) 36 | 37 | #endif /* End Pins P12_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/P3_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: P3.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_P3_ALIASES_H) /* Pins P3_ALIASES_H */ 18 | #define CY_PINS_P3_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define P3_0 (P3__0__PC) 29 | #define P3_1 (P3__1__PC) 30 | #define P3_2 (P3__2__PC) 31 | #define P3_3 (P3__3__PC) 32 | #define P3_4 (P3__4__PC) 33 | #define P3_5 (P3__5__PC) 34 | #define P3_6 (P3__6__PC) 35 | #define P3_7 (P3__7__PC) 36 | 37 | #endif /* End Pins P3_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/P4_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: P4.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_P4_ALIASES_H) /* Pins P4_ALIASES_H */ 18 | #define CY_PINS_P4_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define P4_0 (P4__0__PC) 29 | #define P4_1 (P4__1__PC) 30 | #define P4_2 (P4__2__PC) 31 | #define P4_3 (P4__3__PC) 32 | #define P4_4 (P4__4__PC) 33 | #define P4_5 (P4__5__PC) 34 | #define P4_6 (P4__6__PC) 35 | #define P4_7 (P4__7__PC) 36 | 37 | #endif /* End Pins P4_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/P5_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: P5.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_P5_ALIASES_H) /* Pins P5_ALIASES_H */ 18 | #define CY_PINS_P5_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define P5_0 (P5__0__PC) 29 | #define P5_1 (P5__1__PC) 30 | #define P5_2 (P5__2__PC) 31 | #define P5_3 (P5__3__PC) 32 | #define P5_4 (P5__4__PC) 33 | #define P5_5 (P5__5__PC) 34 | #define P5_6 (P5__6__PC) 35 | #define P5_7 (P5__7__PC) 36 | 37 | #endif /* End Pins P5_ALIASES_H */ 38 | 39 | /* [] END OF FILE */ 40 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include // for size_t 25 | 26 | #include "WString.h" 27 | #include "Printable.h" 28 | 29 | #define DEC 10 30 | #define HEX 16 31 | #define OCT 8 32 | #define BIN 2 33 | 34 | class Print 35 | { 36 | private: 37 | int write_error; 38 | size_t printNumber(unsigned long, uint8_t); 39 | size_t printFloat(double, uint8_t); 40 | protected: 41 | void setWriteError(int err = 1) { write_error = err; } 42 | public: 43 | Print() : write_error(0) {} 44 | ~Print(){} 45 | 46 | int getWriteError() { return write_error; } 47 | void clearWriteError() { setWriteError(0); } 48 | 49 | virtual size_t write(uint8_t) = 0; 50 | size_t write(const char *str) { 51 | if (str == NULL) return 0; 52 | return write((const uint8_t *)str, strlen(str)); 53 | } 54 | virtual size_t write(const uint8_t *buffer, size_t size); 55 | size_t write(const char *buffer, size_t size) { 56 | return write((const uint8_t *)buffer, size); 57 | } 58 | 59 | size_t print(const __FlashStringHelper *); 60 | size_t print(const String &); 61 | size_t print(const char[]); 62 | size_t print(char); 63 | size_t print(unsigned char, int = DEC); 64 | size_t print(int, int = DEC); 65 | size_t print(unsigned int, int = DEC); 66 | size_t print(long, int = DEC); 67 | size_t print(unsigned long, int = DEC); 68 | size_t print(double, int = 2); 69 | size_t print(const Printable&); 70 | 71 | size_t println(const __FlashStringHelper *); 72 | size_t println(const String &s); 73 | size_t println(const char[]); 74 | size_t println(char); 75 | size_t println(unsigned char, int = DEC); 76 | size_t println(int, int = DEC); 77 | size_t println(unsigned int, int = DEC); 78 | size_t println(long, int = DEC); 79 | size_t println(unsigned long, int = DEC); 80 | size_t println(double, int = 2); 81 | size_t println(const Printable&); 82 | size_t println(void); 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/SPIM_0_PVT.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: .h 3 | * Version 2.50 4 | * 5 | * Description: 6 | * This private header file contains internal definitions for the SPIM 7 | * component. Do not use these definitions directly in your application. 8 | * 9 | * Note: 10 | * 11 | ******************************************************************************** 12 | * Copyright 2012-2015, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | *******************************************************************************/ 17 | 18 | #if !defined(CY_SPIM_PVT_SPIM_0_H) 19 | #define CY_SPIM_PVT_SPIM_0_H 20 | 21 | #include "SPIM_0.h" 22 | 23 | 24 | /********************************** 25 | * Functions with external linkage 26 | **********************************/ 27 | 28 | 29 | /********************************** 30 | * Variables with external linkage 31 | **********************************/ 32 | 33 | extern volatile uint8 SPIM_0_swStatusTx; 34 | extern volatile uint8 SPIM_0_swStatusRx; 35 | 36 | #if(SPIM_0_TX_SOFTWARE_BUF_ENABLED) 37 | extern volatile uint8 SPIM_0_txBuffer[SPIM_0_TX_BUFFER_SIZE]; 38 | extern volatile uint8 SPIM_0_txBufferRead; 39 | extern volatile uint8 SPIM_0_txBufferWrite; 40 | extern volatile uint8 SPIM_0_txBufferFull; 41 | #endif /* (SPIM_0_TX_SOFTWARE_BUF_ENABLED) */ 42 | 43 | #if(SPIM_0_RX_SOFTWARE_BUF_ENABLED) 44 | extern volatile uint8 SPIM_0_rxBuffer[SPIM_0_RX_BUFFER_SIZE]; 45 | extern volatile uint8 SPIM_0_rxBufferRead; 46 | extern volatile uint8 SPIM_0_rxBufferWrite; 47 | extern volatile uint8 SPIM_0_rxBufferFull; 48 | #endif /* (SPIM_0_RX_SOFTWARE_BUF_ENABLED) */ 49 | 50 | #endif /* CY_SPIM_PVT_SPIM_0_H */ 51 | 52 | 53 | /* [] END OF FILE */ 54 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/SPIM_1_PVT.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: .h 3 | * Version 2.50 4 | * 5 | * Description: 6 | * This private header file contains internal definitions for the SPIM 7 | * component. Do not use these definitions directly in your application. 8 | * 9 | * Note: 10 | * 11 | ******************************************************************************** 12 | * Copyright 2012-2015, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | *******************************************************************************/ 17 | 18 | #if !defined(CY_SPIM_PVT_SPIM_1_H) 19 | #define CY_SPIM_PVT_SPIM_1_H 20 | 21 | #include "SPIM_1.h" 22 | 23 | 24 | /********************************** 25 | * Functions with external linkage 26 | **********************************/ 27 | 28 | 29 | /********************************** 30 | * Variables with external linkage 31 | **********************************/ 32 | 33 | extern volatile uint8 SPIM_1_swStatusTx; 34 | extern volatile uint8 SPIM_1_swStatusRx; 35 | 36 | #if(SPIM_1_TX_SOFTWARE_BUF_ENABLED) 37 | extern volatile uint8 SPIM_1_txBuffer[SPIM_1_TX_BUFFER_SIZE]; 38 | extern volatile uint8 SPIM_1_txBufferRead; 39 | extern volatile uint8 SPIM_1_txBufferWrite; 40 | extern volatile uint8 SPIM_1_txBufferFull; 41 | #endif /* (SPIM_1_TX_SOFTWARE_BUF_ENABLED) */ 42 | 43 | #if(SPIM_1_RX_SOFTWARE_BUF_ENABLED) 44 | extern volatile uint8 SPIM_1_rxBuffer[SPIM_1_RX_BUFFER_SIZE]; 45 | extern volatile uint8 SPIM_1_rxBufferRead; 46 | extern volatile uint8 SPIM_1_rxBufferWrite; 47 | extern volatile uint8 SPIM_1_rxBufferFull; 48 | #endif /* (SPIM_1_RX_SOFTWARE_BUF_ENABLED) */ 49 | 50 | #endif /* CY_SPIM_PVT_SPIM_1_H */ 51 | 52 | 53 | /* [] END OF FILE */ 54 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/SPI_MODE_REG.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: SPI_Mode_Reg.h 3 | * Version 1.80 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_CONTROL_REG_SPI_Mode_Reg_H) /* CY_CONTROL_REG_SPI_Mode_Reg_H */ 18 | #define CY_CONTROL_REG_SPI_Mode_Reg_H 19 | 20 | #include "cytypes.h" 21 | 22 | 23 | /*************************************** 24 | * Data Struct Definitions 25 | ***************************************/ 26 | 27 | /* Sleep Mode API Support */ 28 | typedef struct 29 | { 30 | uint8 controlState; 31 | 32 | } SPI_Mode_Reg_BACKUP_STRUCT; 33 | 34 | 35 | /*************************************** 36 | * Function Prototypes 37 | ***************************************/ 38 | 39 | void SPI_Mode_Reg_Write(uint8 control) ; 40 | uint8 SPI_Mode_Reg_Read(void) ; 41 | 42 | void SPI_Mode_Reg_SaveConfig(void) ; 43 | void SPI_Mode_Reg_RestoreConfig(void) ; 44 | void SPI_Mode_Reg_Sleep(void) ; 45 | void SPI_Mode_Reg_Wakeup(void) ; 46 | 47 | 48 | /*************************************** 49 | * Registers 50 | ***************************************/ 51 | 52 | /* Control Register */ 53 | #define SPI_Mode_Reg_Control (* (reg8 *) SPI_Mode_Reg_Sync_ctrl_reg__CONTROL_REG ) 54 | #define SPI_Mode_Reg_Control_PTR ( (reg8 *) SPI_Mode_Reg_Sync_ctrl_reg__CONTROL_REG ) 55 | 56 | #endif /* End CY_CONTROL_REG_SPI_Mode_Reg_H */ 57 | 58 | 59 | /* [] END OF FILE */ 60 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server : public Print { 26 | public: 27 | virtual void begin() =0; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/ServoInterrupt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: ServoInterrupt.h 3 | * Version 1.70 4 | * 5 | * Description: 6 | * Provides the function definitions for the Interrupt Controller. 7 | * 8 | * 9 | ******************************************************************************** 10 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 11 | * You may use this file only in accordance with the license, terms, conditions, 12 | * disclaimers, and limitations in the end user license agreement accompanying 13 | * the software package with which this file was provided. 14 | *******************************************************************************/ 15 | #if !defined(CY_ISR_ServoInterrupt_H) 16 | #define CY_ISR_ServoInterrupt_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | /* Interrupt Controller API. */ 23 | void ServoInterrupt_Start(void); 24 | void ServoInterrupt_StartEx(cyisraddress address); 25 | void ServoInterrupt_Stop(void); 26 | 27 | CY_ISR_PROTO(ServoInterrupt_Interrupt); 28 | 29 | void ServoInterrupt_SetVector(cyisraddress address); 30 | cyisraddress ServoInterrupt_GetVector(void); 31 | 32 | void ServoInterrupt_SetPriority(uint8 priority); 33 | uint8 ServoInterrupt_GetPriority(void); 34 | 35 | void ServoInterrupt_Enable(void); 36 | uint8 ServoInterrupt_GetState(void); 37 | void ServoInterrupt_Disable(void); 38 | 39 | void ServoInterrupt_SetPending(void); 40 | void ServoInterrupt_ClearPending(void); 41 | 42 | 43 | /* Interrupt Controller Constants */ 44 | 45 | /* Address of the INTC.VECT[x] register that contains the Address of the ServoInterrupt ISR. */ 46 | #define ServoInterrupt_INTC_VECTOR ((reg32 *) ServoInterrupt__INTC_VECT) 47 | 48 | /* Address of the ServoInterrupt ISR priority. */ 49 | #define ServoInterrupt_INTC_PRIOR ((reg8 *) ServoInterrupt__INTC_PRIOR_REG) 50 | 51 | /* Priority of the ServoInterrupt interrupt. */ 52 | #define ServoInterrupt_INTC_PRIOR_NUMBER ServoInterrupt__INTC_PRIOR_NUM 53 | 54 | /* Address of the INTC.SET_EN[x] byte to bit enable ServoInterrupt interrupt. */ 55 | #define ServoInterrupt_INTC_SET_EN ((reg32 *) ServoInterrupt__INTC_SET_EN_REG) 56 | 57 | /* Address of the INTC.CLR_EN[x] register to bit clear the ServoInterrupt interrupt. */ 58 | #define ServoInterrupt_INTC_CLR_EN ((reg32 *) ServoInterrupt__INTC_CLR_EN_REG) 59 | 60 | /* Address of the INTC.SET_PD[x] register to set the ServoInterrupt interrupt state to pending. */ 61 | #define ServoInterrupt_INTC_SET_PD ((reg32 *) ServoInterrupt__INTC_SET_PD_REG) 62 | 63 | /* Address of the INTC.CLR_PD[x] register to clear the ServoInterrupt interrupt. */ 64 | #define ServoInterrupt_INTC_CLR_PD ((reg32 *) ServoInterrupt__INTC_CLR_PD_REG) 65 | 66 | 67 | #endif /* CY_ISR_ServoInterrupt_H */ 68 | 69 | 70 | /* [] END OF FILE */ 71 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | Stream.h - base class for character-based streams. 3 | Copyright (c) 2010 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | parsing functions based on TextFinder library by Michael Margolis 20 | */ 21 | 22 | #ifndef Stream_h 23 | #define Stream_h 24 | 25 | #include 26 | #include "Print.h" 27 | 28 | // compatability macros for testing 29 | /* 30 | #define getInt() parseInt() 31 | #define getInt(skipChar) parseInt(skipchar) 32 | #define getFloat() parseFloat() 33 | #define getFloat(skipChar) parseFloat(skipChar) 34 | #define getString( pre_string, post_string, buffer, length) 35 | readBytesBetween( pre_string, terminator, buffer, length) 36 | */ 37 | 38 | class Stream : public Print 39 | { 40 | protected: 41 | unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read 42 | unsigned long _startMillis; // used for timeout measurement 43 | int timedRead(); // private method to read stream with timeout 44 | int timedPeek(); // private method to peek stream with timeout 45 | int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout 46 | 47 | public: 48 | ~Stream(){} 49 | virtual int available() = 0; 50 | virtual int read() = 0; 51 | virtual int peek() = 0; 52 | virtual void flush() = 0; 53 | 54 | Stream() {_timeout=1000;} 55 | 56 | // parsing methods 57 | 58 | void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second 59 | 60 | bool find(char *target); // reads data from the stream until the target string is found 61 | bool find(uint8_t *target) { return find ((char *)target); } 62 | // returns true if target string is found, false if timed out (see setTimeout) 63 | 64 | bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found 65 | bool find(uint8_t *target, size_t length) { return find ((char *)target, length); } 66 | // returns true if target string is found, false if timed out 67 | 68 | bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found 69 | bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); } 70 | 71 | bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found 72 | bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } 73 | 74 | 75 | long parseInt(); // returns the first valid (long) integer value from the current position. 76 | // initial characters that are not digits (or the minus sign) are skipped 77 | // integer is terminated by the first character that is not a digit. 78 | 79 | float parseFloat(); // float version of parseInt 80 | 81 | size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer 82 | size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } 83 | // terminates if length characters have been read or timeout (see setTimeout) 84 | // returns the number of characters placed in the buffer (0 means no valid data found) 85 | 86 | size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character 87 | size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } 88 | // terminates if length characters have been read, timeout, or if the terminator character detected 89 | // returns the number of characters placed in the buffer (0 means no valid data found) 90 | 91 | // Arduino String functions to be added here 92 | String readString(); 93 | String readStringUntil(char terminator); 94 | 95 | protected: 96 | long parseInt(char skipChar); // as above but the given skipChar is ignored 97 | // as above but the given skipChar is ignored 98 | // this allows format characters (typically commas) in values to be ignored 99 | 100 | float parseFloat(char skipChar); // as above but the given skipChar is ignored 101 | }; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Tone_Interrupt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: Tone_Interrupt.h 3 | * Version 1.70 4 | * 5 | * Description: 6 | * Provides the function definitions for the Interrupt Controller. 7 | * 8 | * 9 | ******************************************************************************** 10 | * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. 11 | * You may use this file only in accordance with the license, terms, conditions, 12 | * disclaimers, and limitations in the end user license agreement accompanying 13 | * the software package with which this file was provided. 14 | *******************************************************************************/ 15 | #if !defined(CY_ISR_Tone_Interrupt_H) 16 | #define CY_ISR_Tone_Interrupt_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | /* Interrupt Controller API. */ 23 | void Tone_Interrupt_Start(void); 24 | void Tone_Interrupt_StartEx(cyisraddress address); 25 | void Tone_Interrupt_Stop(void); 26 | 27 | CY_ISR_PROTO(Tone_Interrupt_Interrupt); 28 | 29 | void Tone_Interrupt_SetVector(cyisraddress address); 30 | cyisraddress Tone_Interrupt_GetVector(void); 31 | 32 | void Tone_Interrupt_SetPriority(uint8 priority); 33 | uint8 Tone_Interrupt_GetPriority(void); 34 | 35 | void Tone_Interrupt_Enable(void); 36 | uint8 Tone_Interrupt_GetState(void); 37 | void Tone_Interrupt_Disable(void); 38 | 39 | void Tone_Interrupt_SetPending(void); 40 | void Tone_Interrupt_ClearPending(void); 41 | 42 | 43 | /* Interrupt Controller Constants */ 44 | 45 | /* Address of the INTC.VECT[x] register that contains the Address of the Tone_Interrupt ISR. */ 46 | #define Tone_Interrupt_INTC_VECTOR ((reg32 *) Tone_Interrupt__INTC_VECT) 47 | 48 | /* Address of the Tone_Interrupt ISR priority. */ 49 | #define Tone_Interrupt_INTC_PRIOR ((reg8 *) Tone_Interrupt__INTC_PRIOR_REG) 50 | 51 | /* Priority of the Tone_Interrupt interrupt. */ 52 | #define Tone_Interrupt_INTC_PRIOR_NUMBER Tone_Interrupt__INTC_PRIOR_NUM 53 | 54 | /* Address of the INTC.SET_EN[x] byte to bit enable Tone_Interrupt interrupt. */ 55 | #define Tone_Interrupt_INTC_SET_EN ((reg32 *) Tone_Interrupt__INTC_SET_EN_REG) 56 | 57 | /* Address of the INTC.CLR_EN[x] register to bit clear the Tone_Interrupt interrupt. */ 58 | #define Tone_Interrupt_INTC_CLR_EN ((reg32 *) Tone_Interrupt__INTC_CLR_EN_REG) 59 | 60 | /* Address of the INTC.SET_PD[x] register to set the Tone_Interrupt interrupt state to pending. */ 61 | #define Tone_Interrupt_INTC_SET_PD ((reg32 *) Tone_Interrupt__INTC_SET_PD_REG) 62 | 63 | /* Address of the INTC.CLR_PD[x] register to clear the Tone_Interrupt interrupt. */ 64 | #define Tone_Interrupt_INTC_CLR_PD ((reg32 *) Tone_Interrupt__INTC_CLR_PD_REG) 65 | 66 | 67 | #endif /* CY_ISR_Tone_Interrupt_H */ 68 | 69 | 70 | /* [] END OF FILE */ 71 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/UARTClass.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "Arduino.h" 23 | #include "UARTClass.h" 24 | #include 25 | 26 | // Constructors //////////////////////////////////////////////////////////////// 27 | 28 | UARTClass::UARTClass(bool isUSB, SerialHelperFuncs *helpers) 29 | { 30 | _isUSB = isUSB; 31 | _myHelpers = helpers; 32 | _portIsActive = false; 33 | _appBuffSize = 0; 34 | _appBuffIndex = 0; 35 | _timeout = 10; 36 | if (_isUSB) 37 | { 38 | _portIsActive = true; 39 | } 40 | } 41 | 42 | // Public Methods ////////////////////////////////////////////////////////////// 43 | 44 | void UARTClass::begin(const uint32_t dwBaudRate) 45 | { 46 | if (!_isUSB) 47 | { 48 | _portIsActive = _myHelpers->portEnable(); 49 | _myHelpers->clockAdjust(24000000/(8*dwBaudRate)); 50 | } 51 | } 52 | 53 | void UARTClass::end( void ) 54 | { 55 | if (!_isUSB) 56 | { 57 | _portIsActive = false; 58 | _myHelpers->portDisable(); 59 | } 60 | } 61 | 62 | int UARTClass::available( void ) 63 | { 64 | buffer(); 65 | return _appBuffSize; 66 | } 67 | 68 | int UARTClass::peek( void ) 69 | { 70 | buffer(); 71 | if (_appBuffSize > 0) 72 | { 73 | return _appBuffer[_appBuffIndex]; 74 | } 75 | else 76 | { 77 | return -1; 78 | } 79 | } 80 | 81 | int UARTClass::read( void ) 82 | { 83 | buffer(); 84 | if (_appBuffSize > 0) 85 | { 86 | int temp = _appBuffer[_appBuffIndex++]; 87 | if (_appBuffIndex == _appBuffSize) 88 | { 89 | _appBuffIndex = 0; 90 | _appBuffSize = 0; 91 | } 92 | return temp; 93 | } 94 | else 95 | { 96 | return -1; 97 | } 98 | } 99 | 100 | void UARTClass::flush( void ) 101 | { 102 | if (!_isUSB) 103 | { 104 | _myHelpers->blockForWriteComplete(); 105 | } 106 | } 107 | 108 | uint8_t UARTClass::buffer(void) 109 | { 110 | uint8_t dataBufferSize = _myHelpers->bufferSize(); 111 | 112 | if (dataBufferSize > 0) 113 | { 114 | _myHelpers->getData((_appBuffer+_appBuffSize), dataBufferSize); 115 | _appBuffSize += dataBufferSize; 116 | } 117 | return dataBufferSize; 118 | } 119 | 120 | size_t UARTClass::write( const uint8_t uc_data ) 121 | { 122 | if (!_portIsActive) return 0; 123 | while (_myHelpers->blockForReadyToWrite() == 0) 124 | { /* wait for the port to be ready */ } 125 | _myHelpers->sendData(const_cast(&uc_data), 1); 126 | return 1; 127 | } 128 | 129 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/UARTClass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _UART_CLASS_ 20 | #define _UART_CLASS_ 21 | 22 | #include "HardwareSerial.h" 23 | #include 24 | #include 25 | 26 | struct SerialHelperFuncs 27 | { 28 | int16_t (*bufferSize)(void); 29 | bool (*portEnable)(void); 30 | void (*portDisable)(void); 31 | void (*clockAdjust)(uint16_t newDivider); 32 | void (*sendData)(const uint8_t* buffer, uint16_t size); 33 | uint16_t (*getData)(uint8_t* buffer, uint16_t size); 34 | char (*peekData)(void); 35 | void (*blockForWriteComplete)(void); 36 | uint8_t (*blockForReadyToWrite)(void); 37 | }; 38 | 39 | 40 | class UARTClass : public HardwareSerial 41 | { 42 | public: 43 | UARTClass(bool isUSB, SerialHelperFuncs *helpers); 44 | ~UARTClass(){} 45 | void begin(const uint32_t dwBaudRate); 46 | void end(void); 47 | int available(void); 48 | int peek(void); 49 | int read(void); 50 | void flush(void); 51 | uint8_t buffer(void); 52 | size_t write(const uint8_t c); 53 | using Print::write; // pull in write(str) and write(buf, size) from Print 54 | 55 | operator bool() { return _portIsActive; }; 56 | 57 | private: 58 | bool _isUSB; 59 | uint32_t _baudRate; 60 | bool _portIsActive; 61 | SerialHelperFuncs *_myHelpers; 62 | uint8_t _appBuffer[64]; 63 | int8_t _appBuffSize; 64 | int8_t _appBuffIndex; 65 | uint16_t _timeout; 66 | }; 67 | 68 | #endif // _UART_CLASS_ 69 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/USBUART_Dm_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: USBUART_Dm.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_USBUART_Dm_ALIASES_H) /* Pins USBUART_Dm_ALIASES_H */ 18 | #define CY_PINS_USBUART_Dm_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define USBUART_Dm_0 (USBUART_Dm__0__PC) 29 | 30 | #endif /* End Pins USBUART_Dm_ALIASES_H */ 31 | 32 | /* [] END OF FILE */ 33 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/USBUART_Dp_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: USBUART_Dp.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_USBUART_Dp_ALIASES_H) /* Pins USBUART_Dp_ALIASES_H */ 18 | #define CY_PINS_USBUART_Dp_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define USBUART_Dp_0 (USBUART_Dp__0__PC) 29 | 30 | #endif /* End Pins USBUART_Dp_ALIASES_H */ 31 | 32 | /* [] END OF FILE */ 33 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/USBUART_audio.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: USBUART_audio.h 3 | * Version 2.80 4 | * 5 | * Description: 6 | * Header File for the USBFS component. Contains prototypes and constant values. 7 | * 8 | * Related Document: 9 | * Universal Serial Bus Device Class Definition for Audio Devices Release 1.0 10 | * 11 | ******************************************************************************** 12 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | *******************************************************************************/ 17 | 18 | #if !defined(CY_USBFS_USBUART_audio_H) 19 | #define CY_USBFS_USBUART_audio_H 20 | 21 | #include "cytypes.h" 22 | 23 | 24 | /*************************************** 25 | * Custom Declarations 26 | ***************************************/ 27 | 28 | /* `#START CUSTOM_CONSTANTS` Place your declaration here */ 29 | 30 | /* `#END` */ 31 | 32 | 33 | /*************************************** 34 | * Constants for USBUART_audio API. 35 | ***************************************/ 36 | 37 | /* Audio Class-Specific Request Codes (AUDIO Table A-9) */ 38 | #define USBUART_REQUEST_CODE_UNDEFINED (0x00u) 39 | #define USBUART_SET_CUR (0x01u) 40 | #define USBUART_GET_CUR (0x81u) 41 | #define USBUART_SET_MIN (0x02u) 42 | #define USBUART_GET_MIN (0x82u) 43 | #define USBUART_SET_MAX (0x03u) 44 | #define USBUART_GET_MAX (0x83u) 45 | #define USBUART_SET_RES (0x04u) 46 | #define USBUART_GET_RES (0x84u) 47 | #define USBUART_SET_MEM (0x05u) 48 | #define USBUART_GET_MEM (0x85u) 49 | #define USBUART_GET_STAT (0xFFu) 50 | 51 | /* point Control Selectors (AUDIO Table A-19) */ 52 | #define USBUART_EP_CONTROL_UNDEFINED (0x00u) 53 | #define USBUART_SAMPLING_FREQ_CONTROL (0x01u) 54 | #define USBUART_PITCH_CONTROL (0x02u) 55 | 56 | /* Feature Unit Control Selectors (AUDIO Table A-11) */ 57 | #define USBUART_FU_CONTROL_UNDEFINED (0x00u) 58 | #define USBUART_MUTE_CONTROL (0x01u) 59 | #define USBUART_VOLUME_CONTROL (0x02u) 60 | #define USBUART_BASS_CONTROL (0x03u) 61 | #define USBUART_MID_CONTROL (0x04u) 62 | #define USBUART_TREBLE_CONTROL (0x05u) 63 | #define USBUART_GRAPHIC_EQUALIZER_CONTROL (0x06u) 64 | #define USBUART_AUTOMATIC_GAIN_CONTROL (0x07u) 65 | #define USBUART_DELAY_CONTROL (0x08u) 66 | #define USBUART_BASS_BOOST_CONTROL (0x09u) 67 | #define USBUART_LOUDNESS_CONTROL (0x0Au) 68 | 69 | #define USBUART_SAMPLE_FREQ_LEN (3u) 70 | #define USBUART_VOLUME_LEN (2u) 71 | 72 | #if !defined(USER_SUPPLIED_DEFAULT_VOLUME_VALUE) 73 | #define USBUART_VOL_MIN_MSB (0x80u) 74 | #define USBUART_VOL_MIN_LSB (0x01u) 75 | #define USBUART_VOL_MAX_MSB (0x7Fu) 76 | #define USBUART_VOL_MAX_LSB (0xFFu) 77 | #define USBUART_VOL_RES_MSB (0x00u) 78 | #define USBUART_VOL_RES_LSB (0x01u) 79 | #endif /* USER_SUPPLIED_DEFAULT_VOLUME_VALUE */ 80 | 81 | 82 | /*************************************** 83 | * External data references 84 | ***************************************/ 85 | 86 | extern volatile uint8 USBUART_currentSampleFrequency[USBUART_MAX_EP] 87 | [USBUART_SAMPLE_FREQ_LEN]; 88 | extern volatile uint8 USBUART_frequencyChanged; 89 | extern volatile uint8 USBUART_currentMute; 90 | extern volatile uint8 USBUART_currentVolume[USBUART_VOLUME_LEN]; 91 | extern volatile uint8 USBUART_minimumVolume[USBUART_VOLUME_LEN]; 92 | extern volatile uint8 USBUART_maximumVolume[USBUART_VOLUME_LEN]; 93 | extern volatile uint8 USBUART_resolutionVolume[USBUART_VOLUME_LEN]; 94 | 95 | #endif /* CY_USBFS_USBUART_audio_H */ 96 | 97 | 98 | /* [] END OF FILE */ 99 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/USBUART_cdc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: USBUART_cdc.h 3 | * Version 2.80 4 | * 5 | * Description: 6 | * Header File for the USBFS component. 7 | * Contains CDC class prototypes and constant values. 8 | * 9 | * Related Document: 10 | * Universal Serial Bus Class Definitions for Communication Devices Version 1.1 11 | * 12 | ******************************************************************************** 13 | * Copyright 2012-2014, Cypress Semiconductor Corporation. All rights reserved. 14 | * You may use this file only in accordance with the license, terms, conditions, 15 | * disclaimers, and limitations in the end user license agreement accompanying 16 | * the software package with which this file was provided. 17 | *******************************************************************************/ 18 | 19 | #if !defined(CY_USBFS_USBUART_cdc_H) 20 | #define CY_USBFS_USBUART_cdc_H 21 | 22 | #include "cytypes.h" 23 | 24 | 25 | /*************************************** 26 | * Prototypes of the USBUART_cdc API. 27 | ***************************************/ 28 | 29 | #if (USBUART_ENABLE_CDC_CLASS_API != 0u) 30 | void USBUART_CDC_Init(void) ; 31 | void USBUART_PutData(const uint8* pData, uint16 length) ; 32 | void USBUART_PutString(const char8 string[]) ; 33 | void USBUART_PutChar(char8 txDataByte) ; 34 | void USBUART_PutCRLF(void) ; 35 | uint16 USBUART_GetCount(void) ; 36 | uint8 USBUART_CDCIsReady(void) ; 37 | uint8 USBUART_DataIsReady(void) ; 38 | uint16 USBUART_GetData(uint8* pData, uint16 length) ; 39 | uint16 USBUART_GetAll(uint8* pData) ; 40 | uint8 USBUART_GetChar(void) ; 41 | uint8 USBUART_IsLineChanged(void) ; 42 | uint32 USBUART_GetDTERate(void) ; 43 | uint8 USBUART_GetCharFormat(void) ; 44 | uint8 USBUART_GetParityType(void) ; 45 | uint8 USBUART_GetDataBits(void) ; 46 | uint16 USBUART_GetLineControl(void) ; 47 | #endif /* USBUART_ENABLE_CDC_CLASS_API */ 48 | 49 | 50 | /*************************************** 51 | * Constants for USBUART_cdc API. 52 | ***************************************/ 53 | 54 | /* CDC Class-Specific Request Codes (CDC ver 1.2 Table 19) */ 55 | #define USBUART_CDC_SET_LINE_CODING (0x20u) 56 | #define USBUART_CDC_GET_LINE_CODING (0x21u) 57 | #define USBUART_CDC_SET_CONTROL_LINE_STATE (0x22u) 58 | 59 | #define USBUART_LINE_CODING_CHANGED (0x01u) 60 | #define USBUART_LINE_CONTROL_CHANGED (0x02u) 61 | 62 | #define USBUART_1_STOPBIT (0x00u) 63 | #define USBUART_1_5_STOPBITS (0x01u) 64 | #define USBUART_2_STOPBITS (0x02u) 65 | 66 | #define USBUART_PARITY_NONE (0x00u) 67 | #define USBUART_PARITY_ODD (0x01u) 68 | #define USBUART_PARITY_EVEN (0x02u) 69 | #define USBUART_PARITY_MARK (0x03u) 70 | #define USBUART_PARITY_SPACE (0x04u) 71 | 72 | #define USBUART_LINE_CODING_SIZE (0x07u) 73 | #define USBUART_LINE_CODING_RATE (0x00u) 74 | #define USBUART_LINE_CODING_STOP_BITS (0x04u) 75 | #define USBUART_LINE_CODING_PARITY (0x05u) 76 | #define USBUART_LINE_CODING_DATA_BITS (0x06u) 77 | 78 | #define USBUART_LINE_CONTROL_DTR (0x01u) 79 | #define USBUART_LINE_CONTROL_RTS (0x02u) 80 | 81 | 82 | /*************************************** 83 | * External data references 84 | ***************************************/ 85 | 86 | extern volatile uint8 USBUART_lineCoding[USBUART_LINE_CODING_SIZE]; 87 | extern volatile uint8 USBUART_lineChanged; 88 | extern volatile uint16 USBUART_lineControlBitmap; 89 | extern volatile uint8 USBUART_cdc_data_in_ep; 90 | extern volatile uint8 USBUART_cdc_data_out_ep; 91 | 92 | #endif /* CY_USBFS_USBUART_cdc_H */ 93 | 94 | 95 | /* [] END OF FILE */ 96 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/USBUART_hid.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: USBUART_hid.h 3 | * Version 2.80 4 | * 5 | * Description: 6 | * Header File for the USBFS component. Contains prototypes and constant values. 7 | * 8 | * Related Document: 9 | * Device Class Definition for Human Interface Devices (HID) Version 1.11 10 | * 11 | ******************************************************************************** 12 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 13 | * You may use this file only in accordance with the license, terms, conditions, 14 | * disclaimers, and limitations in the end user license agreement accompanying 15 | * the software package with which this file was provided. 16 | *******************************************************************************/ 17 | 18 | #if !defined(CY_USBFS_USBUART_hid_H) 19 | #define CY_USBFS_USBUART_hid_H 20 | 21 | #include "cytypes.h" 22 | 23 | 24 | /*************************************** 25 | * Prototypes of the USBUART_hid API. 26 | ***************************************/ 27 | 28 | uint8 USBUART_UpdateHIDTimer(uint8 interface) ; 29 | uint8 USBUART_GetProtocol(uint8 interface) ; 30 | 31 | 32 | /*************************************** 33 | *Renamed Functions for backward compatible 34 | ***************************************/ 35 | 36 | #define USBUART_bGetProtocol USBUART_GetProtocol 37 | 38 | 39 | /*************************************** 40 | * Constants for USBUART_hid API. 41 | ***************************************/ 42 | 43 | #define USBUART_PROTOCOL_BOOT (0x00u) 44 | #define USBUART_PROTOCOL_REPORT (0x01u) 45 | 46 | /* Request Types (HID Chapter 7.2) */ 47 | #define USBUART_HID_GET_REPORT (0x01u) 48 | #define USBUART_HID_GET_IDLE (0x02u) 49 | #define USBUART_HID_GET_PROTOCOL (0x03u) 50 | #define USBUART_HID_SET_REPORT (0x09u) 51 | #define USBUART_HID_SET_IDLE (0x0Au) 52 | #define USBUART_HID_SET_PROTOCOL (0x0Bu) 53 | 54 | /* Descriptor Types (HID Chapter 7.1) */ 55 | #define USBUART_DESCR_HID_CLASS (0x21u) 56 | #define USBUART_DESCR_HID_REPORT (0x22u) 57 | #define USBUART_DESCR_HID_PHYSICAL (0x23u) 58 | 59 | /* Report Request Types (HID Chapter 7.2.1) */ 60 | #define USBUART_HID_GET_REPORT_INPUT (0x01u) 61 | #define USBUART_HID_GET_REPORT_OUTPUT (0x02u) 62 | #define USBUART_HID_GET_REPORT_FEATURE (0x03u) 63 | 64 | #endif /* CY_USBFS_USBUART_hid_H */ 65 | 66 | 67 | /* [] END OF FILE */ 68 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/Udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Udp.cpp: Library to send/receive UDP packets. 3 | * 4 | * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) 5 | * 1) UDP does not guarantee the order in which assembled UDP packets are received. This 6 | * might not happen often in practice, but in larger network topologies, a UDP 7 | * packet can be received out of sequence. 8 | * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being 9 | * aware of it. Again, this may not be a concern in practice on small local networks. 10 | * For more information, see http://www.cafeaulait.org/course/week12/35.html 11 | * 12 | * MIT License: 13 | * Copyright (c) 2008 Bjoern Hartmann 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | * 32 | * bjoern@cs.stanford.edu 12/30/2008 33 | */ 34 | 35 | #ifndef udp_h 36 | #define udp_h 37 | 38 | #include 39 | #include 40 | 41 | class UDP : public Stream { 42 | 43 | public: 44 | virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use 45 | virtual void stop() =0; // Finish with the UDP socket 46 | 47 | // Sending UDP packets 48 | 49 | // Start building up a packet to send to the remote host specific in ip and port 50 | // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port 51 | virtual int beginPacket(IPAddress ip, uint16_t port) =0; 52 | // Start building up a packet to send to the remote host specific in host and port 53 | // Returns 1 if successful, 0 if there was a problem resolving the hostname or port 54 | virtual int beginPacket(const char *host, uint16_t port) =0; 55 | // Finish off this packet and send it 56 | // Returns 1 if the packet was sent successfully, 0 if there was an error 57 | virtual int endPacket() =0; 58 | // Write a single byte into the packet 59 | virtual size_t write(uint8_t) =0; 60 | // Write size bytes from buffer into the packet 61 | virtual size_t write(const uint8_t *buffer, size_t size) =0; 62 | 63 | // Start processing the next available incoming packet 64 | // Returns the size of the packet in bytes, or 0 if no packets are available 65 | virtual int parsePacket() =0; 66 | // Number of bytes remaining in the current packet 67 | virtual int available() =0; 68 | // Read a single byte from the current packet 69 | virtual int read() =0; 70 | // Read up to len bytes from the current packet and place them into buffer 71 | // Returns the number of bytes read, or 0 if none are available 72 | virtual int read(unsigned char* buffer, size_t len) =0; 73 | // Read up to len characters from the current packet and place them into buffer 74 | // Returns the number of characters read, or 0 if none are available 75 | virtual int read(char* buffer, size_t len) =0; 76 | // Return the next byte from the current packet without moving on to the next byte 77 | virtual int peek() =0; 78 | virtual void flush() =0; // Finish reading the current packet 79 | 80 | // Return the IP address of the host who sent the current incoming packet 81 | virtual IPAddress remoteIP() =0; 82 | // Return the port of the host who sent the current incoming packet 83 | virtual uint16_t remotePort() =0; 84 | protected: 85 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/UserButton_aliases.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: UserButton.h 3 | * Version 2.10 4 | * 5 | * Description: 6 | * This file containts Control Register function prototypes and register defines 7 | * 8 | * Note: 9 | * 10 | ******************************************************************************** 11 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | *******************************************************************************/ 16 | 17 | #if !defined(CY_PINS_UserButton_ALIASES_H) /* Pins UserButton_ALIASES_H */ 18 | #define CY_PINS_UserButton_ALIASES_H 19 | 20 | #include "cytypes.h" 21 | #include "cyfitter.h" 22 | 23 | 24 | 25 | /*************************************** 26 | * Constants 27 | ***************************************/ 28 | #define UserButton_0 (UserButton__0__PC) 29 | 30 | #endif /* End Pins UserButton_ALIASES_H */ 31 | 32 | /* [] END OF FILE */ 33 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | extern "C" { 20 | #include "stdlib.h" 21 | #include "stdint.h" 22 | } 23 | #include "WMath.h" 24 | 25 | extern void randomSeed( uint32_t dwSeed ) 26 | { 27 | if ( dwSeed != 0 ) 28 | { 29 | srand( dwSeed ) ; 30 | } 31 | } 32 | 33 | extern long random( long howbig ) 34 | { 35 | if ( howbig == 0 ) 36 | { 37 | return 0 ; 38 | } 39 | 40 | return rand() % howbig; 41 | } 42 | 43 | extern long random( long howsmall, long howbig ) 44 | { 45 | if (howsmall >= howbig) 46 | { 47 | return howsmall; 48 | } 49 | 50 | long diff = howbig - howsmall; 51 | 52 | return random(diff) + howsmall; 53 | } 54 | 55 | extern long map(long x, long in_min, long in_max, long out_min, long out_max) 56 | { 57 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 58 | } 59 | 60 | extern uint16_t makeWord( uint16_t w ) 61 | { 62 | return w ; 63 | } 64 | 65 | extern uint16_t makeWord( uint8_t h, uint8_t l ) 66 | { 67 | return (h << 8) | l ; 68 | } 69 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/WMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_MATH_ 20 | #define _WIRING_MATH_ 21 | 22 | extern long random( long ) ; 23 | extern long random( long, long ) ; 24 | extern void randomSeed( uint32_t dwSeed ) ; 25 | extern long map( long, long, long, long, long ) ; 26 | 27 | extern uint16_t makeWord( uint16_t w ) ; 28 | extern uint16_t makeWord( uint8_t h, uint8_t l ) ; 29 | 30 | #define word(...) makeWord(__VA_ARGS__) 31 | 32 | 33 | #endif /* _WIRING_MATH_ */ 34 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/avr/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 28 | char fmt[20]; 29 | sprintf(fmt, "%%%d.%df", width, prec); 30 | sprintf(sout, fmt, val); 31 | return sout; 32 | } 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/core_cm3_psoc5.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: core_cm3_psoc5.h 3 | * Version 4.20 4 | * 5 | * Description: 6 | * Provides important type information for the PSoC5. This includes types 7 | * necessary for core_cm3.h. 8 | * 9 | * Note: 10 | * Documentation of the API's in this file is located in the 11 | * System Reference Guide provided with PSoC Creator. 12 | * 13 | ******************************************************************************** 14 | * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. 15 | * You may use this file only in accordance with the license, terms, conditions, 16 | * disclaimers, and limitations in the end user license agreement accompanying 17 | * the software package with which this file was provided. 18 | ********************************************************************************/ 19 | 20 | 21 | #if !defined(__CORE_CM3_PSOC5_H__) 22 | #define __CORE_CM3_PSOC5_H__ 23 | 24 | /** Interrupt Number Definition */ 25 | typedef enum IRQn 26 | { 27 | /****** Cortex-M3 Processor Exceptions Numbers ***************************************************/ 28 | NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ 29 | HardFault_IRQn = -13, /*!< 3 Cortex-M3 Hard Fault Interrupt */ 30 | MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */ 31 | BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */ 32 | UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */ 33 | SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */ 34 | DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */ 35 | PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */ 36 | SysTick_IRQn = -1 /*!< 15 Cortex-M3 System Tick Interrupt */ 37 | /****** PSoC5 Peripheral Interrupt Numbers *******************************************************/ 38 | /* Not relevant. All peripheral interrupts are defined by the user */ 39 | } IRQn_Type; 40 | 41 | #include 42 | 43 | #define __CHECK_DEVICE_DEFINES 44 | 45 | #define __CM3_REV 0x0201 46 | 47 | #define __MPU_PRESENT 0 48 | #define __NVIC_PRIO_BITS 3 49 | #define __Vendor_SysTickConfig 0 50 | 51 | #include 52 | 53 | 54 | #endif /* __CORE_CM3_PSOC5_H__ */ 55 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/cydisabledsheets.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_CYDISABLEDSHEETS_H 2 | #define INCLUDED_CYDISABLEDSHEETS_H 3 | 4 | 5 | #endif /* INCLUDED_CYDISABLEDSHEETS_H */ 6 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/cyfitter_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: cyfitter_cfg.h 3 | * 4 | * PSoC Creator 4.0 Update 1 5 | * 6 | * Description: 7 | * This file provides basic startup and mux configration settings 8 | * This file is automatically generated by PSoC Creator. 9 | * 10 | ******************************************************************************** 11 | * Copyright (c) 2007-2016 Cypress Semiconductor. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | ********************************************************************************/ 16 | 17 | #ifndef CYFITTER_CFG_H 18 | #define CYFITTER_CFG_H 19 | 20 | #include "cytypes.h" 21 | 22 | extern void cyfitter_cfg(void); 23 | 24 | /* Analog Set/Unset methods */ 25 | extern void SetAnalogRoutingPumps(uint8 enabled); 26 | extern void ADC_Mux_Set(uint8 channel); 27 | extern void ADC_Mux_Unset(uint8 channel); 28 | 29 | 30 | #endif /* CYFITTER_CFG_H */ 31 | 32 | /*[]*/ 33 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/itoa.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include "itoa.h" 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | extern char* itoa( int value, char *string, int radix ) 27 | { 28 | return ltoa( value, string, radix ) ; 29 | } 30 | 31 | extern char* ltoa( long value, char *string, int radix ) 32 | { 33 | char tmp[33]; 34 | char *tp = tmp; 35 | long i; 36 | unsigned long v; 37 | int sign; 38 | char *sp; 39 | 40 | if ( string == NULL ) 41 | { 42 | return 0 ; 43 | } 44 | 45 | if (radix > 36 || radix <= 1) 46 | { 47 | return 0 ; 48 | } 49 | 50 | sign = (radix == 10 && value < 0); 51 | if (sign) 52 | { 53 | v = -value; 54 | } 55 | else 56 | { 57 | v = (unsigned long)value; 58 | } 59 | 60 | while (v || tp == tmp) 61 | { 62 | i = v % radix; 63 | v = v / radix; 64 | if (i < 10) 65 | *tp++ = i+'0'; 66 | else 67 | *tp++ = i + 'a' - 10; 68 | } 69 | 70 | sp = string; 71 | 72 | if (sign) 73 | *sp++ = '-'; 74 | while (tp > tmp) 75 | *sp++ = *--tp; 76 | *sp = 0; 77 | 78 | return string; 79 | } 80 | 81 | extern char* utoa( unsigned long value, char *string, int radix ) 82 | { 83 | return ultoa( (unsigned long)value, string, (int)radix ) ; 84 | } 85 | 86 | extern char* ultoa( unsigned long value, char *string, int radix ) 87 | { 88 | char tmp[33]; 89 | char *tp = tmp; 90 | long i; 91 | unsigned long v = value; 92 | char *sp; 93 | 94 | if ( string == NULL ) 95 | { 96 | return 0; 97 | } 98 | 99 | if (radix > 36 || radix <= 1) 100 | { 101 | return 0; 102 | } 103 | 104 | while (v || tp == tmp) 105 | { 106 | i = v % radix; 107 | v = v / radix; 108 | if (i < 10) 109 | *tp++ = i+'0'; 110 | else 111 | *tp++ = i + 'a' - 10; 112 | } 113 | 114 | sp = string; 115 | 116 | 117 | while (tp > tmp) 118 | *sp++ = *--tp; 119 | *sp = 0; 120 | 121 | return string; 122 | } 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _ITOA_ 20 | #define _ITOA_ 21 | 22 | #ifdef __cplusplus 23 | extern "C"{ 24 | #endif // __cplusplus 25 | 26 | #if 0 27 | 28 | extern void itoa( int n, char s[] ) ; 29 | 30 | #else 31 | 32 | extern char* itoa( int value, char *string, int radix ) ; 33 | extern char* ltoa( long value, char *string, int radix ) ; 34 | extern char* utoa( unsigned long value, char *string, int radix ) ; 35 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 36 | #endif /* 0 */ 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // _ITOA_ 43 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/main.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | #include 3 | } 4 | 5 | #include "Arduino.h" 6 | 7 | //#define I2C 0 8 | //#define ANALOG 1 9 | //#define DIGITAL 2 10 | 11 | struct SerialHelperFuncs USBUART_Helpers; 12 | struct SerialHelperFuncs UART_Helpers; 13 | UARTClass Serial(true, &USBUART_Helpers); 14 | UARTClass Serial1(false, &UART_Helpers); 15 | 16 | int main() 17 | { 18 | 19 | CyGlobalIntEnable; 20 | Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDB); 21 | USBUART_FunctionAttach(); 22 | enableUSBCDC(); 23 | UART_FunctionAttach(); 24 | initTimebase(); 25 | 26 | setup(); 27 | 28 | for(;;) 29 | { 30 | loop(); 31 | } 32 | } 33 | 34 | 35 | 36 | /* [] END OF FILE */ 37 | 38 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/cores/arduino/project.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * File Name: project.h 3 | * 4 | * PSoC Creator 4.0 Update 1 5 | * 6 | * Description: 7 | * It contains references to all generated header files and should not be modified. 8 | * This file is automatically generated by PSoC Creator. 9 | * 10 | ******************************************************************************** 11 | * Copyright (c) 2007-2016 Cypress Semiconductor. All rights reserved. 12 | * You may use this file only in accordance with the license, terms, conditions, 13 | * disclaimers, and limitations in the end user license agreement accompanying 14 | * the software package with which this file was provided. 15 | ********************************************************************************/ 16 | 17 | #include "cyfitter_cfg.h" 18 | #include "cydevice.h" 19 | #include "cydevice_trm.h" 20 | #include "cyfitter.h" 21 | #include "cydisabledsheets.h" 22 | #include "ADC.h" 23 | #include "ADC_Mux.h" 24 | #include "I2C.h" 25 | #include "I2C_PVT.h" 26 | #include "DB_aliases.h" 27 | #include "D10_Ctrl.h" 28 | #include "D11_Ctrl.h" 29 | #include "SPIM_0.h" 30 | #include "SPIM_0_PVT.h" 31 | #include "PRS.h" 32 | #include "ToneTimer.h" 33 | #include "Micros_Counter.h" 34 | #include "Tone_Interrupt.h" 35 | #include "Millis_Counter.h" 36 | #include "Clock_3.h" 37 | #include "I2C_Enable.h" 38 | #include "USBUART.h" 39 | #include "USBUART_audio.h" 40 | #include "USBUART_cdc.h" 41 | #include "USBUART_hid.h" 42 | #include "USBUART_midi.h" 43 | #include "USBUART_pvt.h" 44 | #include "UART.h" 45 | #include "UART_Clock.h" 46 | #include "HW_INT.h" 47 | #include "SPI_Clock_In.h" 48 | #include "SPIM_1.h" 49 | #include "SPIM_1_PVT.h" 50 | #include "SPI_Mode_Reg.h" 51 | #include "P0_aliases.h" 52 | #include "P3_aliases.h" 53 | #include "P4_aliases.h" 54 | #include "P5_aliases.h" 55 | #include "P12_aliases.h" 56 | #include "UserButton_aliases.h" 57 | #include "UserButton.h" 58 | #include "A_aliases.h" 59 | #include "DA_aliases.h" 60 | #include "DA.h" 61 | #include "ServoInterrupt.h" 62 | #include "Clock_12.h" 63 | #include "ServoCounter.h" 64 | #include "BootloaderResetTimer.h" 65 | #include "BootloaderResetInterrupt.h" 66 | #include "Clock_2.h" 67 | #include "PWM_3.h" 68 | #include "PWM_2.h" 69 | #include "Clock_5.h" 70 | #include "PWM_1.h" 71 | #include "Bootloadable.h" 72 | #include "ADC_IRQ.h" 73 | #include "ADC_theACLK.h" 74 | #include "USBUART_Dm_aliases.h" 75 | #include "USBUART_Dm.h" 76 | #include "USBUART_Dp_aliases.h" 77 | #include "USBUART_Dp.h" 78 | #include "core_cm3_psoc5.h" 79 | #include "core_cm3.h" 80 | #include "CyDmac.h" 81 | #include "CyFlash.h" 82 | #include "CyLib.h" 83 | #include "cypins.h" 84 | #include "cyPm.h" 85 | #include "CySpc.h" 86 | #include "cytypes.h" 87 | #include "core_cmFunc.h" 88 | #include "core_cmInstr.h" 89 | 90 | /*[]*/ 91 | 92 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/KitProg.inf: -------------------------------------------------------------------------------- 1 | ; Installation INF for the Cypress USB3 Driver for Windows 7 2 | ; Processor support for x64 based platforms. 3 | ; 4 | ; (c) Copyright 2014 Cypress Semiconductor Corporation 5 | ; 6 | 7 | [Version] 8 | Signature="$WINDOWS NT$" 9 | Class=USB 10 | ClassGUID={36FC9E60-C465-11CF-8056-444553540000} 11 | provider=%PSoCUSB3_Provider% 12 | CatalogFile=PSoCUSB3.cat 13 | DriverVer=05/02/2013,1.2.3.3 14 | DriverPackageDisplayName=%PSoCUSB3_Description% 15 | 16 | [SourceDisksNames] 17 | 1=%PSoCUSB3_Install%,,, 18 | 19 | [SourceDisksFiles] 20 | PSoCUSB3.sys = 1 21 | 22 | [DestinationDirs] 23 | PSoCUSB3.Files.Ext = 10,system32\drivers\cypress\KitProg 24 | 25 | [ControlFlags] 26 | ExcludeFromSelect = * 27 | 28 | [Manufacturer] 29 | %PSoCUSB3_Provider%=Device, NTamd64 30 | 31 | [Device.NTamd64] 32 | %VID_04B4&PID_F139&MI_01.DeviceDesc%=PSoCUSB3, USB\VID_04B4&PID_F139&MI_01 33 | 34 | [PSoCUSB3.NT] 35 | CopyFiles=PSoCUSB3.Files.Ext 36 | AddReg=PSoCUSB3.AddReg 37 | 38 | [PSoCUSB3.NT.HW] 39 | AddReg=PSoCUSB3.AddReg.Guid 40 | 41 | [PSoCUSB3.NT.Services] 42 | Addservice = PSoCUSB3,2,PSoCUSB3.AddService 43 | 44 | [PSoCUSB3.AddReg] 45 | HKR,,DevLoader,,*ntkern 46 | HKR,,NTMPDriver,,PSoCUSB3.sys 47 | ; You may optionally include a check for DriverBase in your application to check for a PSoCUSB3 driver 48 | HKR,,DriverBase,,PSoCUSB3.sys 49 | HKR,"Parameters","MaximumTransferSize",0x10001,4096 50 | HKR,"Parameters","DebugLevel",0x10001,2 51 | HKR,,FriendlyName,,%PSoCUSB3_Description% 52 | 53 | [PSoCUSB3.AddService] 54 | DisplayName = %PSoCUSB3_Description% 55 | ServiceType = 1 ; SERVICE_KERNEL_DRIVER 56 | StartType = 3 ; SERVICE_DEMAND_START 57 | ErrorControl = 1 ; SERVICE_ERROR_NORMAL 58 | ServiceBinary = %10%\System32\Drivers\Cypress\KitProg\PSoCUSB3.sys 59 | AddReg = PSoCUSB3.AddReg 60 | LoadOrderGroup = Base 61 | 62 | [PSoCUSB3.Files.Ext] 63 | PSoCUSB3.sys 64 | 65 | [PSoCUSB3.AddReg.Guid] 66 | HKR,,DriverGUID,,%PSoCUSB3.GUID% 67 | 68 | ;-------------- WDF Coinstaller installation 69 | [SourceDisksFiles] 70 | WdfCoInstaller01009.dll=1 ; make sure the number matches with SourceDisksNames 71 | 72 | [DestinationDirs] 73 | CoInstaller_CopyFiles = 11 74 | 75 | [PSoCUSB3.NTamd64.CoInstallers] 76 | AddReg=CoInstaller_AddReg 77 | CopyFiles=CoInstaller_CopyFiles 78 | 79 | [CoInstaller_CopyFiles] 80 | WdfCoInstaller01009.dll 81 | 82 | [CoInstaller_AddReg] 83 | HKR,,CoInstallers32,0x00010000, "WdfCoInstaller01009.dll,WdfCoInstaller" 84 | 85 | [PSoCUSB3.NTamd64.Wdf] 86 | KmdfService = PSoCUSB3, PSoCUSB3_wdfsect 87 | 88 | [PSoCUSB3_wdfsect] 89 | KmdfLibraryVersion = 1.9 90 | 91 | [Strings] 92 | PSoCUSB3_Provider = "Cypress" 93 | PSoCUSB3_Company = "Cypress Semiconductor Corporation" 94 | PSoCUSB3_Description = "USB3 Driver for KitProg" 95 | PSoCUSB3_DisplayName = "PSoCUSB3 Device Driver" 96 | PSoCUSB3_Install = "Cypress USB3 Driver Installation Disk" 97 | VID_04B4&PID_F139&MI_01.DeviceDesc="KitProg (1.2.3.3)" 98 | PSoCUSB3.GUID="{43FEF108-580F-11D8-B22B-00B0D0C6A8DC}" 99 | PSoCUSB3_Unused = "." -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/KitProgUSBUART.inf: -------------------------------------------------------------------------------- 1 | ; Windows USB CDC setup file for USBUART User Module 2 | ; (c) Copyright 2013 Cypress Semiconductor Corporation 3 | 4 | [Version] 5 | Signature="$Windows NT$" 6 | Class=Ports 7 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 8 | Provider=%PROVIDER% 9 | CatalogFile=KitProgUart.cat 10 | ;;;LayoutFile=layout.inf 11 | DriverVer=07/19/2009,2.0.0000.0 12 | ;;;DriverPackageDisplayName=%DESCRIPTION% 13 | 14 | [Manufacturer] 15 | %MFGNAME%=DeviceList, NTx86, NTia64, NTamd64 16 | 17 | [DestinationDirs] 18 | DefaultDestDir=12 19 | 20 | [SourceDisksFiles] 21 | 22 | [SourceDisksNames] 23 | 24 | [DeviceList.NTx86] 25 | %DESCRIPTION%=DriverInstall, USB\VID_04b4&PID_f139&MI_02 26 | 27 | 28 | [DeviceList.NTia64] 29 | %DESCRIPTION%=DriverInstall, USB\VID_04b4&PID_f139&MI_02 30 | 31 | [DeviceList.NTamd64] 32 | %DESCRIPTION%=DriverInstall, USB\VID_04b4&PID_f139&MI_02 33 | 34 | 35 | ;------------------------------------------------------------------------------ 36 | ; 32 bit section for Windows 2000/2003/XP/Vista 37 | ;------------------------------------------------------------------------------ 38 | 39 | [DriverInstall.NTx86] 40 | include=mdmcpq.inf 41 | ;;;;CopyFiles=DriverCopyFiles 42 | CopyFiles=FakeModemCopyFileSection 43 | AddReg=DriverInstall.NTx86.AddReg 44 | 45 | ;;;;[DriverCopyFiles] 46 | ;;;;usbser.sys,,,0x20 47 | 48 | [DriverInstall.NTx86.AddReg] 49 | HKR,,DevLoader,,*ntkern 50 | HKR,,NTMPDriver,,usbser.sys 51 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 52 | 53 | [DriverInstall.NTx86.Services] 54 | AddService=usbser, 0x00000002, DriverService 55 | 56 | ;------------------------------------------------------------------------------ 57 | ; 64 bit section for Intel Itanium based systems 58 | ;------------------------------------------------------------------------------ 59 | 60 | [DriverInstall.NTia64] 61 | include=mdmcpq.inf 62 | ;;;;CopyFiles=DriverCopyFiles 63 | CopyFiles=FakeModemCopyFileSection 64 | AddReg=DriverInstall.NTia64.AddReg 65 | 66 | ;;;;[DriverCopyFiles] 67 | ;;;;usbser.sys,,,0x20 68 | 69 | [DriverInstall.NTia64.AddReg] 70 | HKR,,DevLoader,,*ntkern 71 | HKR,,NTMPDriver,,usbser.sys 72 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 73 | 74 | [DriverInstall.NTia64.Services] 75 | AddService=usbser, 0x00000002, DriverService 76 | 77 | ;------------------------------------------------------------------------------ 78 | ; 64 bit section for AMD64 and Intel EM64T based systems 79 | ;------------------------------------------------------------------------------ 80 | 81 | [DriverInstall.NTamd64] 82 | include=mdmcpq.inf 83 | ;;;;CopyFiles=DriverCopyFiles 84 | CopyFiles=FakeModemCopyFileSection 85 | AddReg=DriverInstall.NTamd64.AddReg 86 | 87 | ;;;;[DriverCopyFiles] 88 | ;;;;usbser.sys,,,0x20 89 | 90 | [DriverInstall.NTamd64.AddReg] 91 | HKR,,DevLoader,,*ntkern 92 | HKR,,NTMPDriver,,usbser.sys 93 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 94 | 95 | [DriverInstall.NTamd64.Services] 96 | AddService=usbser, 0x00000002, DriverService 97 | 98 | ;------------------------------------------------------------------------------ 99 | ; 100 | ;------------------------------------------------------------------------------ 101 | 102 | [DriverService] 103 | DisplayName=%SERVICE% 104 | ServiceType=1 105 | StartType=3 106 | ErrorControl=1 107 | ServiceBinary=%12%\usbser.sys 108 | 109 | ;------------------------------------------------------------------------------ 110 | ; String Definitions 111 | ;------------------------------------------------------------------------------ 112 | 113 | [Strings] 114 | PROVIDER="Cypress" 115 | MFGNAME="Cypress" 116 | DESCRIPTION="KitProg USB-UART" 117 | SERVICE="USB RS-232" 118 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/PSoCUSB3.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/drivers/PSoCUSB3.sys -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/USBUART_cdc.inf: -------------------------------------------------------------------------------- 1 | ;****************************************************************************** 2 | ; File Name: USBUART_cdc.inf 3 | ; Version 2.80 4 | ; 5 | ; Description: 6 | ; Windows USB CDC setup file for USBUART Device. 7 | ; 8 | ;****************************************************************************** 9 | ; Copyright 2007-2014, Cypress Semiconductor Corporation. All rights reserved. 10 | ; You may use this file only in accordance with the license, terms, conditions, 11 | ; disclaimers, and limitations in the end user license agreement accompanying 12 | ; the software package with which this file was provided. 13 | ;****************************************************************************** 14 | 15 | [Version] 16 | Signature="$Windows NT$" 17 | Class=Ports 18 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 19 | Provider=%PROVIDER% 20 | LayoutFile=layout.inf 21 | DriverVer=03/05/2007,2.0.0000.0 22 | 23 | [Manufacturer] 24 | %MFGNAME%=DeviceList, NTx86, NTia64, NTamd64 25 | 26 | [DestinationDirs] 27 | DefaultDestDir=12 28 | 29 | [SourceDisksFiles] 30 | 31 | [SourceDisksNames] 32 | 33 | [DeviceList.NTx86] 34 | %DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232 35 | 36 | [DeviceList.NTia64] 37 | %DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232 38 | 39 | [DeviceList.NTamd64] 40 | %DESCRIPTION%=DriverInstall, USB\VID_04B4&PID_F232 41 | 42 | 43 | ;------------------------------------------------------------------------------ 44 | ; 32 bit section for Windows 2000/2003/XP/Vista 45 | ;------------------------------------------------------------------------------ 46 | 47 | [DriverInstall.NTx86] 48 | include=mdmcpq.inf 49 | CopyFiles=DriverCopyFiles 50 | AddReg=DriverInstall.NTx86.AddReg 51 | 52 | [DriverCopyFiles] 53 | usbser.sys,,,0x20 54 | 55 | [DriverInstall.NTx86.AddReg] 56 | HKR,,DevLoader,,*ntkern 57 | HKR,,NTMPDriver,,usbser.sys 58 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 59 | 60 | [DriverInstall.NTx86.Services] 61 | AddService=usbser, 0x00000002, DriverService 62 | 63 | ;------------------------------------------------------------------------------ 64 | ; 64 bit section for Intel Itanium based systems 65 | ;------------------------------------------------------------------------------ 66 | 67 | [DriverInstall.NTia64] 68 | include=mdmcpq.inf 69 | CopyFiles=DriverCopyFiles 70 | AddReg=DriverInstall.NTia64.AddReg 71 | 72 | [DriverCopyFiles] 73 | usbser.sys,,,0x20 74 | 75 | [DriverInstall.NTia64.AddReg] 76 | HKR,,DevLoader,,*ntkern 77 | HKR,,NTMPDriver,,usbser.sys 78 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 79 | 80 | [DriverInstall.NTia64.Services] 81 | AddService=usbser, 0x00000002, DriverService 82 | 83 | ;------------------------------------------------------------------------------ 84 | ; 64 bit section for AMD64 and Intel EM64T based systems 85 | ;------------------------------------------------------------------------------ 86 | 87 | [DriverInstall.NTamd64] 88 | include=mdmcpq.inf 89 | CopyFiles=DriverCopyFiles 90 | AddReg=DriverInstall.NTamd64.AddReg 91 | 92 | [DriverCopyFiles] 93 | usbser.sys,,,0x20 94 | 95 | [DriverInstall.NTamd64.AddReg] 96 | HKR,,DevLoader,,*ntkern 97 | HKR,,NTMPDriver,,usbser.sys 98 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 99 | 100 | [DriverInstall.NTamd64.Services] 101 | AddService=usbser, 0x00000002, DriverService 102 | 103 | ;------------------------------------------------------------------------------ 104 | ; 105 | ;------------------------------------------------------------------------------ 106 | 107 | [DriverService] 108 | DisplayName=%SERVICE% 109 | ServiceType=1 110 | StartType=3 111 | ErrorControl=1 112 | ServiceBinary=%12%\usbser.sys 113 | 114 | ;------------------------------------------------------------------------------ 115 | ; String Definitions 116 | ;------------------------------------------------------------------------------ 117 | 118 | [Strings] 119 | PROVIDER="Cypress" 120 | MFGNAME="Cypress Semiconductor Corporation" 121 | DESCRIPTION="Cypress USB UART" 122 | SERVICE="USB UART" 123 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/WdfCoInstaller01009.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/drivers/WdfCoInstaller01009.dll -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/kitproguart.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/drivers/kitproguart.cat -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/drivers/psocusb3.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/drivers/psocusb3.cat -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/SPI/SPI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 by Cristian Maglie 3 | * Copyright (c) 2014 by Paul Stoffregen (Transaction API) 4 | * SPI Master library for arduino. 5 | * 6 | * This file is free software; you can redistribute it and/or modify 7 | * it under the terms of either the GNU General Public License version 2 8 | * or the GNU Lesser General Public License version 2.1, both as 9 | * published by the Free Software Foundation. 10 | */ 11 | 12 | #include "Arduino.h" 13 | #include "SPI.h" 14 | #include 15 | 16 | SPIClass SPI; 17 | 18 | uint8_t SPIClass::inTransactionFlag; 19 | 20 | SPIClass::SPIClass() 21 | { 22 | SPIM_0_Start(); 23 | SPIM_1_Start(); 24 | inTransactionFlag = 0; 25 | } 26 | 27 | SPIClass::~SPIClass() 28 | { 29 | } 30 | 31 | void SPIClass::begin() 32 | { 33 | // D10_Ctrl and D11_Ctrl are registers which select between PWM and SPI for 34 | // those two pins. 0 is PWM, 1 is SPI. Do this *first* so if the PWM is on 35 | // these pins don't see a bunch of gibberish transitions when we hook the 36 | // peripheral bus up to them. 37 | D10_Ctrl_Write(0x01); 38 | D11_Ctrl_Write(0x01); 39 | pinMode(10, OUTPUT); 40 | digitalWrite(10, HIGH); 41 | pinMode(11, PERIPHERAL_OUT); 42 | pinMode(12, PERIPHERAL_IN); 43 | pinMode(13, PERIPHERAL_OUT); 44 | SPI_Mode_Reg_Write(0x00); 45 | } 46 | 47 | void SPIClass::end() 48 | { 49 | pinMode(10, INPUT); 50 | pinMode(11, INPUT); 51 | pinMode(12, INPUT); 52 | pinMode(13, INPUT); 53 | } 54 | 55 | void SPIClass::setBitOrder(BITORDER _bitOrder) 56 | { 57 | // This is not supported by the native SPI master device provided by 58 | // Cypress. Future support may occur but for now, MSB first only! 59 | } 60 | 61 | void SPIClass::setDataMode(SPI_MODE spiMode) 62 | { 63 | // The SPI_M peripheral provided by Cypress doesn't support dynamic mode 64 | // changing; however, we can game it a bit by running the output through 65 | // some digital logic on the way off chip. 66 | // We run the clock output of the SPI module through an XOR gate, and MISO 67 | // and MOSI through a MUX which allows to select either the native signal 68 | // or the signal run through a D flip flop which is clocked by the clock 69 | // going into the SPI module. The SCLK of the SPI module is 1/2 the input 70 | // frequency, so the one-cycle delay of the D-ff is actually a 1/2 SCLK 71 | // cycle delay. 72 | // These changes are controlled by the SPI_MODE_REG register; writing the 73 | // MODE value (0, 1, 2, 3) to that register will configure the logic for 74 | // the signal properly. 75 | SPI_Mode_Reg_Write(spiMode); 76 | } 77 | 78 | void SPIClass::setClockDivider(uint8_t _divider) 79 | { 80 | /* The clock output is determined by the input clock to the SPI module. That 81 | * is, in turn, determined by the divider we write here. The output freq is 82 | * (IMO / _divider) / 2; IMO is nominally 24MHz. 83 | * The maximum frequency out is 9 MHz; maximum in is thus 18MHz 84 | * However, since IMO is 24MHz, and the divider is an integer, we can't do 85 | * better than 12 MHz input, or a by-two division.*/ 86 | if (_divider < 2) 87 | { 88 | return; 89 | } 90 | SPI_Clock_In_SetDividerValue(_divider); 91 | } 92 | 93 | uint8_t SPIClass::transfer(uint8_t _data) 94 | { 95 | digitalWrite(10, LOW); 96 | uint8_t temp = 0; 97 | if ((SPI_Mode_Reg_Read() & 0x02) == 0) 98 | { 99 | while (SPIM_0_GetTxBufferSize() > 0) 100 | { /* wait for data to be sent */} 101 | SPIM_0_WriteTxData(_data); 102 | while (SPIM_0_GetTxBufferSize() > 0) 103 | { /* wait for data to be sent */} 104 | temp = SPIM_0_ReadRxData(); 105 | } 106 | else 107 | { 108 | while (SPIM_1_GetTxBufferSize() > 0) 109 | { /* wait for data to be sent */} 110 | SPIM_1_WriteTxData(_data); 111 | while (SPIM_1_GetTxBufferSize() > 0) 112 | { /* wait for data to be sent */} 113 | temp = SPIM_1_ReadRxData(); 114 | } 115 | digitalWrite(10, HIGH); 116 | return temp; 117 | } 118 | 119 | void SPIClass::transfer(uint8_t *_buf, size_t _count) 120 | { 121 | digitalWrite(10, LOW); 122 | if ((SPI_Mode_Reg_Read() & 0x02) == 0) 123 | { 124 | while ((SPIM_0_ReadTxStatus() & SPIM_0_STS_SPI_DONE) == 0) 125 | { /* wait for data to be sent */ } 126 | for (size_t i = 0; i < _count; i++) 127 | { 128 | SPIM_0_WriteTxData(*(_buf + i)); 129 | } 130 | while ((SPIM_0_ReadTxStatus() & SPIM_0_STS_SPI_DONE) == 0) 131 | { /* wait for data to be sent */ } 132 | for (unsigned int j = 0; j<_count; j++) 133 | { 134 | *(_buf + j) = SPIM_0_ReadRxData(); 135 | } 136 | } 137 | else 138 | { 139 | while ((SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE) == 0) 140 | { /* wait for data to be sent */ } 141 | for (size_t i = 0; i < _count; i++) 142 | { 143 | SPIM_1_WriteTxData(*(_buf + i)); 144 | } 145 | while ((SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE) == 0) 146 | { /* wait for data to be sent */ } 147 | for (unsigned int j = 0; j<_count; j++) 148 | { 149 | *(_buf + j) = SPIM_1_ReadRxData(); 150 | } 151 | } 152 | digitalWrite(10, HIGH); 153 | } 154 | 155 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/SPI/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 by Cristian Maglie 3 | * Copyright (c) 2014 by Paul Stoffregen (Transaction API) 4 | * SPI Master library for arduino. 5 | * 6 | * This file is free software; you can redistribute it and/or modify 7 | * it under the terms of either the GNU General Public License version 2 8 | * or the GNU Lesser General Public License version 2.1, both as 9 | * published by the Free Software Foundation. 10 | */ 11 | 12 | #ifndef _SPI_H_INCLUDED 13 | #define _SPI_H_INCLUDED 14 | 15 | #include 16 | #include "Arduino.h" 17 | 18 | #define SPI_HAS_TRANSACTION 0 19 | //#define SPI_HAS_EXTENDED_CS_PIN_HANDLING 0 20 | 21 | enum SPI_MODE { 22 | SPI_MODE0 = 0, 23 | SPI_MODE1 = 1, 24 | SPI_MODE2 = 2, 25 | SPI_MODE3 = 3 26 | }; 27 | 28 | enum BITORDER { 29 | MSB_FIRST, 30 | LSB_FIRST 31 | }; 32 | 33 | class SPISettings { 34 | public: 35 | SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) 36 | { 37 | _clock = clock; 38 | _dataMode = dataMode; 39 | init_AlwaysInline(clock, bitOrder, dataMode); 40 | } 41 | SPISettings() 42 | { 43 | _clock = 4000000; 44 | _dataMode = SPI_MODE0; 45 | init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); 46 | } 47 | 48 | private: 49 | uint32_t _clock; 50 | uint8_t _dataMode; 51 | void init_AlwaysInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) 52 | __attribute__((__always_inline__)) 53 | { 54 | // As of this writing (July 2016) it's not possible to configure the bit 55 | // order at runtime (at least, not easily), so we ignore it and leave it as 56 | // MSB first. 57 | // SPI_MODE_REG_Write(dataMode); 58 | // The SPI clock frequency is set by a divider, from a nominal of 12MHz. We 59 | // just let the division find the closest integer value; it'll be equal to, 60 | // or lower than, the desired clock frequency. 61 | SPI_Clock_In_SetDividerValue(12000000/clock); 62 | } 63 | friend class SPIClass; 64 | }; 65 | 66 | class SPIClass 67 | { 68 | private: 69 | static uint8_t inTransactionFlag; 70 | 71 | public: 72 | SPIClass(); 73 | ~SPIClass(); 74 | 75 | // Transfer functions 76 | uint8_t transfer(uint8_t _data); 77 | void transfer(uint8_t *_buf, size_t _count); 78 | 79 | void begin(void); 80 | void end(void); 81 | 82 | // These methods sets a parameter on a single pin 83 | void setBitOrder(enum BITORDER _order); 84 | void setDataMode(enum SPI_MODE spiMode); 85 | void setClockDivider(uint8_t); 86 | 87 | inline static void beginTransaction(SPISettings settings) 88 | { 89 | if (inTransactionFlag) 90 | { 91 | return; 92 | } 93 | inTransactionFlag = 1; 94 | // Cringe. Because of the way this was written originally, adhering to the 95 | // same structure means de-encapsulation of SPISettings. I don't like it 96 | // either, but here we are. 97 | settings.init_AlwaysInline(settings._clock, 0, settings._dataMode); 98 | } 99 | 100 | inline static void endTransaction( void ) 101 | { 102 | inTransactionFlag = 0; 103 | } 104 | 105 | }; 106 | 107 | 108 | 109 | 110 | extern SPIClass SPI; 111 | 112 | // For compatibility with sketches designed for AVR @ 16 MHz 113 | // New programs should use SPI.beginTransaction to set the SPI clock 114 | #define SPI_CLOCK_DIV2 3 // yields 8MHz 115 | #define SPI_CLOCK_DIV4 6 // yields 4MHz 116 | #define SPI_CLOCK_DIV8 12 // yields 2MHz 117 | #define SPI_CLOCK_DIV16 24 // yields 1MHz 118 | #define SPI_CLOCK_DIV32 48 // yields 500kHz 119 | #define SPI_CLOCK_DIV64 96 // yields 250kHz 120 | #define SPI_CLOCK_DIV128 192 // yields 125hHz 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Servo/.Servo.cpp.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/libraries/Servo/.Servo.cpp.swp -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Servo/.Servo.h.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/libraries/Servo/.Servo.h.swp -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Servo/Servo.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include 4 | } 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | volatile uint8_t pinStatus = LOW; 11 | volatile uint8_t pinStatus2 = LOW; 12 | volatile uint16_t pulseLength = DEFAULT_PULSE_WIDTH; 13 | static servo_t servoList[MAX_SERVOS]; 14 | static int8_t servoCount = 0; 15 | static int8_t activeServo = 0; 16 | extern uint32_t pinNumberToPointer[NUM_BASE_PINS]; 17 | 18 | CY_ISR_PROTO(ServoInterrupt_ISR); 19 | CY_ISR(ServoInterrupt_ISR) 20 | { 21 | // Reading the status register clears the interrupt, so we *have* to do it. 22 | uint8_t status = ServoCounter_STATUS; 23 | 24 | // However, if we've no servos attached, we don't need to do anything else. 25 | if (servoCount == 0) 26 | { 27 | return; 28 | } 29 | 30 | if ( ( status & ServoCounter_STATUS_ZERO ) !=0 ) 31 | { 32 | digitalWrite(D4, HIGH); 33 | digitalWrite(D4, LOW); 34 | } 35 | 36 | /* If a zero status interrupt occurred, we need to reset the active servo 37 | * index to zero. */ 38 | 39 | if (activeServo == servoCount) 40 | { 41 | ServoCounter_WriteCompare(0); 42 | activeServo = 0; 43 | return; 44 | } 45 | 46 | if (servoList[activeServo].Pin.isActive == false) 47 | { 48 | activeServo++; 49 | return; 50 | } 51 | 52 | /* If a compare interrupt occurred, we want to 53 | - toggle the current active PWM pin 54 | - set the compare register to trip at the next event 55 | */ 56 | uint32_t pinName = servoList[activeServo].Pin.nbr; 57 | if ( ( status & ServoCounter_STATUS_CMP ) != 0 ) 58 | { 59 | if (CyPins_ReadPin(pinName) == LOW) 60 | { 61 | CyPins_SetPin(pinName); 62 | ServoCounter_WriteCompare((activeServo * CHANNEL_SWITCH_TIME)+servoList[activeServo].ticks); 63 | } 64 | else 65 | { 66 | CyPins_ClearPin(pinName); 67 | ++activeServo; 68 | ServoCounter_WriteCompare(activeServo * CHANNEL_SWITCH_TIME); 69 | } 70 | } 71 | } 72 | 73 | 74 | Servo::Servo() 75 | { 76 | 77 | if (servoCount < MAX_SERVOS) 78 | { 79 | this->servoIndex = servoCount++; 80 | servoList[this->servoIndex].ticks = DEFAULT_PULSE_WIDTH; 81 | } 82 | else 83 | { 84 | this->servoIndex = INVALID_SERVO; 85 | } 86 | } 87 | 88 | 89 | uint8_t Servo::attach(uint32_t pin) 90 | { 91 | return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); 92 | } 93 | 94 | uint8_t Servo::attach(uint32_t pin, int min, int max) 95 | { 96 | if ( (ServoCounter_ReadControlRegister() & 0x80) == 0 ) 97 | { 98 | ServoCounter_Start(); 99 | ServoCounter_WritePeriod(25000); 100 | ServoCounter_WriteCompare(0); 101 | ServoCounter_SetInterruptMode(ServoCounter_STATUS_CMP_INT_EN_MASK | ServoCounter_STATUS_ZERO_INT_EN_MASK); 102 | ServoInterrupt_StartEx(ServoInterrupt_ISR); 103 | } 104 | if (this->servoIndex != INVALID_SERVO) 105 | { 106 | if ( (pin > 0 ) && (pin < 20) ) 107 | { 108 | pin = pinNumberToPointer[pin]; 109 | } 110 | pinMode(pin, OUTPUT); 111 | servoList[this->servoIndex].Pin.nbr = pin; 112 | this->min = min; 113 | this->max = max; 114 | servoList[this->servoIndex].Pin.isActive = 1; 115 | } 116 | return this->servoIndex; 117 | } 118 | 119 | void Servo::detach() 120 | { 121 | pinMode(servoList[this->servoIndex].Pin.nbr, INPUT); 122 | servoList[this->servoIndex].Pin.isActive = 0; 123 | } 124 | 125 | void Servo::write(int value) 126 | { 127 | if (value <= 180) 128 | { 129 | value = map(value, 0, 180, this->min, this->max); 130 | writeMicroseconds(value); 131 | } 132 | if ( (value <= this->max) && (value >= this->min)) 133 | { 134 | writeMicroseconds(value); 135 | } 136 | } 137 | 138 | void Servo::writeMicroseconds(int value) 139 | { 140 | servoList[this->servoIndex].ticks = value; 141 | } 142 | 143 | int Servo::read() 144 | { 145 | return map(servoList[this->servoIndex].ticks, this->min, this->max, 0, 180); 146 | } 147 | 148 | int Servo::readMicroseconds() 149 | { 150 | return servoList[this->servoIndex].ticks; 151 | } 152 | 153 | bool Servo::attached() 154 | { 155 | return (bool)servoList[this->servoIndex].Pin.isActive; 156 | } 157 | 158 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Servo/Servo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 3 | Copyright (c) 2009 Michael Margolis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /* 21 | A servo is activated by creating an instance of the Servo class passing 22 | the desired pin to the attach() method. 23 | The servos are pulsed in the background using the value most recently 24 | written using the write() method. 25 | 26 | Note that analogWrite of PWM on pins associated with the timer are 27 | disabled when the first servo is attached. 28 | Timers are seized as needed in groups of 12 servos - 24 servos use two 29 | timers, 48 servos will use four. 30 | The sequence used to sieze timers is defined in timers.h 31 | 32 | The methods are: 33 | 34 | Servo - Class for manipulating servo motors connected to Arduino pins. 35 | 36 | attach(pin ) - Attaches a servo motor to an i/o pin. 37 | attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds 38 | default min is 544, max is 2400 39 | 40 | write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) 41 | writeMicroseconds() - Sets the servo pulse width in microseconds 42 | read() - Gets the last written servo pulse width as an angle between 0 and 180. 43 | readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) 44 | attached() - Returns true if there is a servo attached. 45 | detach() - Stops an attached servos from pulsing its i/o pin. 46 | */ 47 | 48 | #ifndef Servo_h 49 | #define Servo_h 50 | 51 | #include 52 | 53 | /* 54 | * Defines for 16 bit timers used with Servo library 55 | * 56 | * If _useTimerX is defined then TimerX is a 16 bit timer on the current board 57 | * timer16_Sequence_t enumerates the sequence that the timers should be allocated 58 | * _Nbr_16timers indicates how many 16 bit timers are available. 59 | */ 60 | 61 | #define MIN_PULSE_WIDTH 350 // the shortest pulse sent to a servo 62 | #define MAX_PULSE_WIDTH 2500 // the longest pulse sent to a servo 63 | #define CHANNEL_SWITCH_TIME 2080 // how often to start a new pulse 64 | #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 65 | #define REFRESH_INTERVAL 25000 // time to refresh servos in microseconds 66 | 67 | #define MAX_SERVOS 12 68 | 69 | #define INVALID_SERVO 255 // flag indicating an invalid servo index 70 | 71 | 72 | typedef struct { 73 | uint32_t nbr; // a pin number from 0 to 63 74 | uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false 75 | } ServoPin_t ; 76 | 77 | typedef struct { 78 | ServoPin_t Pin; 79 | volatile uint16_t ticks; 80 | } servo_t; 81 | 82 | class Servo 83 | { 84 | public: 85 | Servo(); 86 | uint8_t attach(uint32_t pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure 87 | uint8_t attach(uint32_t pin, int min, int max); // as above but also sets min and max values for writes. 88 | void detach(); 89 | void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds 90 | void writeMicroseconds(int value); // Write pulse width in microseconds 91 | int read(); // returns current pulse width as an angle between 0 and 180 degrees 92 | int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) 93 | bool attached(); // return true if this servo is attached, otherwise false 94 | private: 95 | uint8_t servoIndex; // index into the channel data for this servo 96 | int16_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH 97 | int16_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH 98 | }; 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/WS281x/WS281x.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "WS281x.h" 4 | 5 | WS281x::WS281x(uint8_t nLEDs, uint8_t pin, COLOR_ORDER order, 6 | BIT_RATE speed): 7 | _numLEDs(nLEDs), _pin(pin), _brightness(255) 8 | { 9 | _type.order = order; 10 | _type.speed = speed; 11 | _pixels = new uint8_t [3*_numLEDs]; 12 | } 13 | 14 | void WS281x::begin() 15 | { 16 | pinMode(_pin + P0_D0, PERIPHERAL_OUT); 17 | WSDriver_Start(); 18 | for (int i = 0; i < _numLEDs; i++) 19 | { 20 | WSDriver_Pixel(i, _pin, 0); 21 | } 22 | WSDriver_Dim(0); 23 | } 24 | 25 | void WS281x::end() 26 | { 27 | WSDriver_Stop(); 28 | pinMode(_pin + P0_D0, INPUT); 29 | } 30 | 31 | void WS281x::refresh() 32 | { 33 | WSDriver_Trigger(1); 34 | } 35 | 36 | void WS281x::setPixelColor(uint8_t LEDNum, uint8_t r, uint8_t g, uint8_t b) 37 | { 38 | *(_pixels+(LEDNum*3)) = r; 39 | *(_pixels+(LEDNum*3)+1) = g; 40 | *(_pixels+(LEDNum*3)+2) = b; 41 | uint32_t color = 0; 42 | if (_brightness == 0) 43 | { 44 | color = 0; 45 | } 46 | else if (_brightness == 255) 47 | { 48 | // The under-the-hood component writes the data out in the order received, 49 | // so store it according to the byte order. 50 | if ( (_type.order & COLOR_ORDER_MASK) == RGB) 51 | { 52 | color = (r) + (g<<8) + (b<<16); 53 | } 54 | else 55 | { 56 | color = (r<<8) + (g) + (b<<16); 57 | } 58 | } 59 | else 60 | { 61 | r *= _brightness; 62 | g *= _brightness; 63 | b *= _brightness; 64 | if ( (_type.order & COLOR_ORDER_MASK) == RGB) 65 | { 66 | color = (r) + (g<<8) + (b<<16); 67 | } 68 | else 69 | { 70 | color = (r<<8) + (g) + (b<<16); 71 | } 72 | } 73 | WSDriver_Pixel(LEDNum, _pin, color); 74 | } 75 | 76 | void WS281x::setPixelColor(uint8_t LEDNum, uint32_t c) 77 | { 78 | setPixelColor(LEDNum, (uint8_t)c>>16, (uint8_t)c>>8, (uint8_t)c); 79 | } 80 | 81 | void WS281x::setBrightness(uint8_t brightness) 82 | { 83 | _brightness = brightness; 84 | } 85 | 86 | uint8_t WS281x::getNumPixels(void) 87 | { 88 | return _numLEDs; 89 | } 90 | 91 | uint32_t WS281x::makeColor(uint8_t r, uint8_t g, uint8_t b) 92 | { 93 | return (r<<16) + (g<<8) + b; 94 | } 95 | 96 | uint32_t WS281x::getPixelColor(uint16_t n) 97 | { 98 | uint32_t color; 99 | color = *(_pixels+(n*3))<<16; 100 | color += *(_pixels+(n*3)+1)<<8; 101 | color += *(_pixels+(n*3)+2); 102 | return color; 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/WS281x/WS281x.h: -------------------------------------------------------------------------------- 1 | #ifndef PSOC_WS281x_H 2 | #define PSOC_WS281x_H 3 | 4 | #include 5 | 6 | enum COLOR_ORDER {RGB=0x00, GRB=0x01}; 7 | #define COLOR_ORDER_MASK 0x01 8 | enum BIT_RATE {_400K=0x00, _800K=0x02}; 9 | #define BIT_RATE_MASK 0x02 10 | 11 | class WS281x 12 | { 13 | public: 14 | 15 | WS281x(uint8_t nLEDs, uint8_t pin=0, COLOR_ORDER order=GRB, 16 | BIT_RATE speed=_800K); 17 | 18 | void begin(void); 19 | void end(void); 20 | 21 | void refresh(void); 22 | void setPixelColor(uint8_t LEDNum, uint8_t r, uint8_t g, uint8_t b); 23 | void setPixelColor(uint8_t LEDNum, uint32_t c); 24 | void setBrightness(uint8_t brightness); 25 | uint8_t getNumPixels(void); 26 | static uint32_t makeColor(uint8_t r, uint8_t g, uint8_t b); 27 | uint32_t getPixelColor(uint16_t n); 28 | 29 | private: 30 | 31 | uint16_t _numLEDs; // Number of RGB LEDs in strip 32 | uint16_t _numBytes; // Size of 'pixels' buffer below 33 | uint8_t _pin; // Output pin number 34 | struct partInfo 35 | { 36 | COLOR_ORDER order; 37 | BIT_RATE speed; 38 | } _type; 39 | uint8_t *_pixels; 40 | uint8_t _brightness; 41 | }; 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Wire/Arduino_I2C.cpp: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | 13 | 14 | extern "C" { 15 | #include 16 | } 17 | 18 | #include "stdint.h" 19 | #include "Arduino_I2C.h" 20 | #include "Arduino_Pins.h" 21 | 22 | #define BUS_CLOCK_RATE 24000000 23 | 24 | TwoWire Wire = TwoWire(); 25 | 26 | void TwoWire::begin() 27 | { 28 | pinMode(A4, PERIPHERAL_OD); 29 | pinMode(A5, PERIPHERAL_OD); 30 | I2C_Enable_Write(0x01); 31 | I2C_Start(); 32 | } 33 | 34 | void TwoWire::setClock(uint32_t newClockRate) 35 | { 36 | uint32_t clockDivider = (1/BUS_CLOCK_RATE)*newClockRate; 37 | twiClock = newClockRate; 38 | *(uint8_t*)(CYREG_I2C_CLK_DIV1) = (uint8_t)clockDivider; 39 | *(uint8_t*)(CYREG_I2C_CLK_DIV1) = (uint8_t)((clockDivider>>8)&0x02); 40 | 41 | } 42 | void TwoWire::beginTransmission(uint8_t address) 43 | { 44 | slaveAddress = address; 45 | } 46 | 47 | void TwoWire::beginTransmission(int address) 48 | { 49 | slaveAddress = (uint8_t) address; 50 | } 51 | 52 | uint8_t TwoWire::endTransmission(enum XFER_MODE stop) 53 | { 54 | I2C_MasterClearStatus(); 55 | 56 | if (stop == COMPLETE) 57 | { 58 | I2C_MasterWriteBuf(slaveAddress, i2cTXBuffer, i2cTXBufferSize, \ 59 | I2C_MODE_COMPLETE_XFER); 60 | } 61 | else if (stop == REPEATED_START) 62 | { 63 | I2C_MasterWriteBuf(slaveAddress, i2cTXBuffer, i2cTXBufferSize, \ 64 | I2C_MODE_REPEAT_START); 65 | } 66 | else 67 | { 68 | I2C_MasterWriteBuf(slaveAddress, i2cTXBuffer, i2cTXBufferSize, \ 69 | I2C_MODE_NO_STOP); 70 | } 71 | 72 | while(0u != (I2C_MasterStatus() & I2C_MSTAT_XFER_INP)); 73 | i2cTXBufferSize = 0; 74 | return 0; 75 | } 76 | 77 | uint8_t TwoWire::endTransmission() 78 | { 79 | return endTransmission(COMPLETE); 80 | } 81 | 82 | uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, \ 83 | enum XFER_MODE stop) 84 | { 85 | I2C_MasterClearStatus(); 86 | 87 | if (stop == COMPLETE) 88 | { 89 | I2C_MasterReadBuf(address, i2cRXBuffer, quantity, \ 90 | I2C_MODE_COMPLETE_XFER); 91 | } 92 | else if (stop == REPEATED_START) 93 | { 94 | I2C_MasterReadBuf(address, i2cRXBuffer, quantity, \ 95 | I2C_MODE_REPEAT_START); 96 | } 97 | else 98 | { 99 | I2C_MasterReadBuf(address, i2cRXBuffer, quantity, I2C_MODE_NO_STOP); 100 | } 101 | 102 | while(0u == (I2C_MasterStatus() & I2C_MSTAT_RD_CMPLT)); 103 | i2cRXBufferSize = quantity; 104 | return quantity; 105 | } 106 | 107 | uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) 108 | { 109 | return requestFrom(address, quantity, COMPLETE); 110 | } 111 | 112 | uint8_t TwoWire::requestFrom(int address, int quantity) 113 | { 114 | return requestFrom((uint8_t)address, (uint8_t)quantity, (enum XFER_MODE)COMPLETE); 115 | } 116 | 117 | uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) 118 | { 119 | return requestFrom((uint8_t) address, (uint8_t) quantity, (enum XFER_MODE)sendStop); 120 | } 121 | 122 | size_t TwoWire::write(uint8_t *buffer, uint8_t length) 123 | { 124 | uint8_t i; 125 | if (i2cTXBufferSize == 32) 126 | { 127 | txOverflow = 1; 128 | return 0; 129 | } 130 | for (i=0; i < length; i++) 131 | { 132 | i2cTXBuffer[i2cTXBufferSize+i] = buffer[i]; 133 | if (++i2cTXBufferSize == 32) 134 | { 135 | txOverflow = 1; 136 | return i+1; 137 | } 138 | } 139 | return i; 140 | } 141 | 142 | size_t TwoWire::write(uint8_t buffer) 143 | { 144 | return write((uint8_t *)&buffer, 1); 145 | } 146 | 147 | int TwoWire::available() 148 | { 149 | return i2cRXBufferSize; 150 | } 151 | 152 | int TwoWire::read() 153 | { 154 | if (i2cRXBufferSize == 0) return -1; 155 | return i2cRXBuffer[--i2cRXBufferSize]; 156 | } 157 | 158 | int TwoWire::peek() 159 | { 160 | if (i2cRXBufferSize == 0) return -1; 161 | return i2cRXBuffer[i2cRXBufferSize]; 162 | } 163 | 164 | void TwoWire::flush() 165 | { 166 | } 167 | 168 | /* [] END OF FILE */ 169 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Wire/Arduino_I2C.h: -------------------------------------------------------------------------------- 1 | #ifndef _arduino_i2c_h 2 | #define _arduino_i2c_h 3 | 4 | #include "Project.h" 5 | #include "Stream.h" 6 | 7 | enum XFER_MODE {COMPLETE, REPEATED_START, NO_STOP}; 8 | 9 | class TwoWire; 10 | 11 | extern TwoWire Wire; 12 | 13 | class TwoWire : public Stream 14 | { 15 | public: 16 | TwoWire(){}; 17 | void begin(); 18 | //void begin(uint8_t); TODO: add slave support? 19 | //void begin(int); TODO: add slave support? 20 | 21 | void setClock(uint32_t); // TODO: implement this 22 | 23 | void beginTransmission(uint8_t address); 24 | void beginTransmission(int address); 25 | 26 | uint8_t endTransmission(); 27 | uint8_t endTransmission(enum XFER_MODE stop); 28 | 29 | uint8_t requestFrom(uint8_t address, uint8_t quantity, \ 30 | enum XFER_MODE stop); 31 | uint8_t requestFrom(uint8_t address, uint8_t quantity); 32 | uint8_t requestFrom(int address, int quantity); 33 | uint8_t requestFrom(int address, int quantity, int sendStop); 34 | 35 | virtual size_t write(uint8_t *buffer, uint8_t length); 36 | virtual size_t write(uint8_t buffer); 37 | 38 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 39 | inline size_t write(long n) { return write((uint8_t)n); } 40 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 41 | inline size_t write(int n) { return write((uint8_t)n); } 42 | 43 | virtual int available(); 44 | virtual int read(); 45 | virtual int peek(); 46 | virtual void flush(); 47 | 48 | //TODO: Implement these for slave mode? 49 | //void onReceive(void(*)(int)); 50 | //void onRequest(void(*)(void)); 51 | 52 | private: 53 | uint32_t twiClock; 54 | uint8_t i2cRXBuffer[128]; 55 | uint8_t i2cTXBuffer[32]; 56 | uint8_t i2cRXBufferSize; 57 | uint8_t i2cTXBufferSize; 58 | uint8_t slaveAddress; 59 | uint8_t txOverflow; 60 | uint8_t rxOverflow; 61 | }; 62 | 63 | #endif 64 | 65 | /* [] END OF FILE */ 66 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/libraries/Wire/Wire.h: -------------------------------------------------------------------------------- 1 | /* ======================================== 2 | * 3 | * Copyright YOUR COMPANY, THE YEAR 4 | * All Rights Reserved 5 | * UNPUBLISHED, LICENSED SOFTWARE. 6 | * 7 | * CONFIDENTIAL AND PROPRIETARY INFORMATION 8 | * WHICH IS THE PROPERTY OF your company. 9 | * 10 | * ======================================== 11 | */ 12 | #include 13 | /* [] END OF FILE */ 14 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/platform.txt: -------------------------------------------------------------------------------- 1 | # For more info: 2 | # https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification 3 | 4 | name=SparkFun PSoC Development Boards 5 | version=1.6.3 6 | 7 | compiler.path={runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/ 8 | compiler.c.cmd=arm-none-eabi-gcc 9 | compiler.c.flags=-D NDEBUG -Wall -ffunction-sections -g -c -Os -mcpu=cortex-m3 -mthumb -Wno-main 10 | 11 | compiler.c.elf.cmd=arm-none-eabi-gcc 12 | compiler.c.elf.flags= 13 | 14 | compiler.S.flags=-mcpu=cortex-m3 -mthumb -g 15 | compiler.S.cmd=arm-none-eabi-as 16 | 17 | compiler.cpp.cmd=arm-none-eabi-gcc 18 | compiler.cpp.flags=-x c++ -D NDEBUG -Wall -ffunction-sections -g -c -Os -mcpu=cortex-m3 -mthumb -Wno-main -Wno-exceptions 19 | 20 | compiler.ar.cmd=arm-none-eabi-ar 21 | compiler.ar.flags=rcs 22 | 23 | compiler.objcopy.cmd=arm-none-eabi-objcopy 24 | compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 25 | 26 | compiler.elf2hex.flags=-O ihex -R .cyeeprom -R .cyconfigecc -R .cycustnvl -R .cywolatch -R .cyflashprotect -R .cybootloader -R .cyloadablemeta -R .cyloadermeta -R .cymeta 27 | #compiler.elf2hex.flags=-O ihex 28 | compiler.elf2hex.cmd=arm-none-eabi-objcopy 29 | 30 | compiler.ldflags= 31 | 32 | compiler.size.cmd=arm-none-eabi-size 33 | compiler.define=-DARDUINO= 34 | 35 | # this can be overriden in boards.txt 36 | build.extra_flags= 37 | 38 | # These can be overridden in platform.local.txt 39 | compiler.c.extra_flags= 40 | compiler.c.elf.extra_flags= 41 | compiler.cpp.extra_flags= 42 | compiler.ar.extra_flags= 43 | compiler.elf2hex.extra_flags= 44 | 45 | #local_libraries={runtime.hardware.path}/psoc/Libraries/ 46 | 47 | ## Compile c files 48 | recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" 49 | 50 | ## Compile c++ files 51 | recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" 52 | 53 | ## Assemble .S files 54 | recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {includes} "{source_file}" -o "{object_file}" 55 | 56 | ## Create archives 57 | recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}" 58 | 59 | ## Combine gc-sections, archives, and objects 60 | recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -Wl,--start-group -o "{build.path}/{build.project_name}.elf" {object_files} "{build.variant.path}/Uno_blocks.a" "{build.variant.path}/{build.variant_system_lib}" "{build.path}/core/core.a" -mthumb -march=armv7-m -mfix-cortex-m3-ldrd -lm "-Wl,-Map,{build.path}/{build.project_name}.map" "-T{runtime.hardware.path}/psoc/cores/arduino/cm3gcc.ld" -g "-u _printf_float" "" -Wl,--gc-sections -Wl,--end-group -lstdc++ 61 | recipe.objcopy.eep.pattern= 62 | 63 | ## Create hex 64 | recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" 65 | 66 | ## Compute size 67 | recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" 68 | recipe.size.regex=\.text\s+([0-9]+).* 69 | 70 | ## Upload 71 | tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin 72 | tools.avrdude.conf.path={runtime.hardware.path}/psoc/avrdude.conf 73 | tools.avrdude.cmd=avrdude 74 | tools.avrdude.upload.params.verbose= 75 | tools.avrdude.upload.params.quiet= 76 | tools.avrdude.upload.pattern="{cmd.path}/{cmd}" -ppsoc -C "{conf.path}" -v -c {upload.protocol} -P{serial.port} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i" 77 | 78 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/programmers.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/programmers.txt -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/variants/standard/CyCompLib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/variants/standard/CyCompLib.a -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/variants/standard/Uno_blocks.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/Hardware/SparkFun/psoc/variants/standard/Uno_blocks.a -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/variants/standard/variant.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include "variant.h" 20 | 21 | -------------------------------------------------------------------------------- /Hardware/SparkFun/psoc/variants/standard/variant.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _VARIANT_ARDUINO_DUE_X_ 20 | #define _VARIANT_ARDUINO_DUE_X_ 21 | #endif /* _VARIANT_ARDUINO_DUE_X_ */ 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PSoC Arduino Support 2 | ======================================== 3 | 4 | [![FreeSoC2](https://cdn.sparkfun.com//assets/parts/1/1/2/0/8/13714-01.jpg)](https://www.sparkfun.com/products/13714) 5 | 6 | [*SparkFun FreeSoC2 (DEV-13714)*](https://www.sparkfun.com/products/13714) 7 | 8 | Support projects for PSoC processor support within the Arduino IDE. You will need to [manually install the board files as explained in the hookup guide](https://learn.sparkfun.com/tutorials/freesoc2-hookup-guide-v14#using-the-arduino-ide). 9 | 10 | Documentation 11 | -------------- 12 | * **[GitHub Product Repo](https://github.com/sparkfun/FreeSoc2)** - Product Repo for the FreeSoC2 Development Board - PSoC5LP 13 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/freesoc2-hookup-guide-v14)** - Basic hookup guide for the FreeSoC2. 14 | 15 | Product Versions 16 | ---------------- 17 | * [DEV-13714](https://www.sparkfun.com/products/13714) - V14 18 | * _[DEV-13229 (RETIRED)](https://www.sparkfun.com/products/13229)- Initial Release_ 19 | 20 | License Information 21 | ------------------- 22 | This product is _**open source**_! 23 | 24 | The **hardware** is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). 25 | 26 | The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! 27 | 28 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 29 | 30 | Distributed as-is; no warranty is given. 31 | 32 | - Your friends at SparkFun. 33 | 34 | Collaborators 35 | ------------- 36 | 37 | Thanks to Jon Moeller, for creating the first FreeSoC board and providing terrific feedback during the development of the FreeSoC2. 38 | Thanks to Cypress Semiconductor, for providing feedback and working with us closely to ensure that the FreeSoC2 was the right product for the time. 39 | -------------------------------------------------------------------------------- /tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/PSoC_Arduino_Support/857718cf63ddfee09217269843adb31675f87304/tags --------------------------------------------------------------------------------