Commit 149fcee8 authored by Xavier Piroux's avatar Xavier Piroux

added SPI implementation provided by EnergyMicro , created file for implementing…

added SPI implementation provided by EnergyMicro , created file for implementing driver FAT on SD through SPI
parent 1e35b26c
......@@ -5,12 +5,14 @@
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
-include Makefile.$(USER) #user specific rules
####################################################################
# Definitions #
####################################################################
DEVICE = EFM32GG330F1024
PROJECTNAME = freertos_blink
PROJECTNAME = freertos_blink_fat
# Name of interface configuration file used by OpenOCD
OOCD_IFACE ?= stlink-v2-1
......@@ -26,7 +28,7 @@ LST_DIR = lst
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.7 2012q4
LINUXCS ?= /usr
LINUXCS ?= /opt/gcc-arm-none-eabi-4_8-2014q1
RMDIRS := rm -rf
RMFILES := rm -rf
......@@ -172,7 +174,7 @@ C_SRC += \
C_SRC += \
../reptile/FreeRTOS-Plus-FAT-SL/fat_sl/test/test.c \
../reptile/FreeRTOS-Plus-FAT-SL/psp/target/fat_sl/psp_test_xavier.c #TODO: we should not use this psp_test.c because it use printf() to simulate
../reptile/FreeRTOS-Plus-FAT-SL/psp/target/fat_sl/psp_test_ramdrv.c #This file test FAT SL with a given driver : now it uses the RAM driver
INCLUDEPATHS += \
-I../reptile/FreeRTOS-Plus-FAT-SL/config/ \
......
......@@ -48,7 +48,7 @@
#define MDRIVER_RAM_SECTOR_SIZE 512 /* Sector size */
#define MDRIVER_RAM_VOLUME0_SIZE (128 * 1024) /* defintion for size of ramdrive0 */
#define MDRIVER_RAM_VOLUME0_SIZE (32 * 1024) /* defintion for size of ramdrive0 */
#define MDRIVER_MEM_LONG_ACCESS 1 /* set this value to 1 if 32bit access available */
......
/*
* TODO : license
*/
#ifndef _CONFIG_MDRIVER_SD_H_
#define _CONFIG_MDRIVER_SD_H_
#include "../version/ver_mdriver_sd.h"
#if VER_MDRIVER_SD_MAJOR != 1 || VER_MDRIVER_SD_MINOR != 0
#error Incompatible MDRIVER_SD version number!
#endif
#define PIN_UC_PC3 12
#define PIN_UC_PD0 28
#define PIN_UC_PD1 29
#define PIN_UC_PD2 30
#define PIN_UC_PD3 31
#define PIN_UC_SD_MOSI PIN_UC_PD0
#define PIN_UC_SD_MISO PIN_UC_PD1
#define PIN_UC_SD_CLK PIN_UC_PD2
#define PIN_UC_SD_CS_N PIN_UC_PD3
/* usage : add those pins values to GPIO_BASE */
#endif /* _CONFIG_MDRIVER_SD_H_ */
/*
* TODO : license
*/
//TODO: use those CMD to send it through SPI interface
/* MMC/SD command (in SPI) */
#define USD_CMD0 (0x40+0) /* GO_IDLE_STATE */
#define USD_CMD1 (0x40+1) /* SEND_OP_COND (MMC) */
#define USD_ACMD41 (0xC0+41) /* SEND_OP_COND (SDC) */
#define USD_CMD8 (0x40+8) /* SEND_IF_COND */
#define USD_CMD9 (0x40+9) /* SEND_CSD */
#define USD_CMD10 (0x40+10) /* SEND_CID */
#define USD_CMD12 (0x40+12) /* STOP_TRANSMISSION */
#define USD_ACMD13 (0xC0+13) /* SD_STATUS (SDC) */
#define USD_CMD16 (0x40+16) /* SET_BLOCKLEN */
#define USD_CMD17 (0x40+17) /* READ_SINGLE_BLOCK */
#define USD_CMD18 (0x40+18) /* READ_MULTIPLE_BLOCK */
#define USD_CMD23 (0x40+23) /* SET_BLOCK_COUNT (MMC) */
#define USD_ACMD23 (0xC0+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */
#define USD_CMD24 (0x40+24) /* WRITE_BLOCK */
#define USD_CMD25 (0x40+25) /* WRITE_MULTIPLE_BLOCK */
#define USD_CMD55 (0x40+55) /* APP_CMD */
#define USD_CMD58 (0x40+58) /* READ_OCR */
static int sd_readsector ( F_DRIVER * driver, void * data, unsigned long sector ) {
//TODO:implement sd_readsector
return -1;
}
static int sd_writesector ( F_DRIVER * driver, void * data, unsigned long sector ) {
//TODO:implement sd_writesector
return -1;
}
static int sd_getphy ( F_DRIVER * driver, F_PHY * phy ) {
//TODO:implement sd_getphy
return -1;
}
static void sd_release ( F_DRIVER * driver ) {
//TODO:implement sd_release
return;
}
F_DRIVER * sd_initfunc ( unsigned long driver_param ) {
//TODO:implement sd_initfunc
/* Enabling clock to USART 0*/
CMU_ClockEnable(cmuClock_USART0, true);
SPI_setup(USART0_NUM, GPIO_POS1, false);
return NULL;
}
This diff is collapsed.
/**************************************************************************//**
* @file
* @brief SPI prototypes and definitions
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __SPI_H
#define __SPI_H
#include <stdbool.h>
#include "em_device.h"
void SPI_setup(uint8_t spiNumber, uint8_t location, bool master);
void SPI0_setupRXInt(char* receiveBuffer, int bytesToReceive);
void SPI0_setupSlaveInt(char* receiveBuffer, int receiveBufferSize, char* transmitBuffer, int transmitBufferSize);
#endif
/**************************************************************************//**
* @file
* @brief SPI Example Header File
*
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __SPI_PROJECT_H
#define __SPI_PROJECT_H
/* Defines */
#define HFRCO_FREQUENCY 14000000
#define SPI_PERCLK_FREQUENCY HFRCO_FREQUENCY
#define SPI_BAUDRATE 1000000
#endif
/**************************************************************************//**
* @file
* @brief USART example
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#include "em_device.h"
#include "usart.h"
#include "em_gpio.h"
/******************************************************************************
* @brief sends data using USART0
* @param txBuffer points to data to transmit
* @param bytesToSend bytes will be sent
*****************************************************************************/
void USART0_sendBuffer(char* txBuffer, int bytesToSend)
{
USART_TypeDef *uart = USART0;
int ii;
/* Sending the data */
for (ii = 0; ii < bytesToSend; ii++)
{
/* Waiting for the usart to be ready */
while (!(uart->STATUS & USART_STATUS_TXBL)) ;
if (txBuffer != 0)
{
/* Writing next byte to USART */
uart->TXDATA = *txBuffer;
txBuffer++;
}
else
{
uart->TXDATA = 0;
}
}
/*Waiting for transmission of last byte */
while (!(uart->STATUS & USART_STATUS_TXC)) ;
}
/**************************************************************************//**
* @file
* @brief USART prototypes and definitions
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __USART_H
#define __USART_H
#include <stdbool.h>
#include "em_device.h"
#define NO_RX 0
#define NO_TX NO_RX
#define USART0_NUM 0
#define USART1_NUM 1
#define USART2_NUM 2
#define GPIO_POS0 0
#define GPIO_POS1 1
#define GPIO_POS2 2
void USART0_sendBuffer(char*, int);
#endif
/*
* TODO : license
*/
#ifndef _VER_MDRIVER_SD_H
#define _VER_MDRIVER_SD_H
#define VER_MDRIVER_SD_MAJOR 1
#define VER_MDRIVER_SD_MINOR 0
#endif /* _VER_MDRIVER_SD_H /*
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_opt.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
</Extensions>
<DaveTm>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DaveTm>
<Target>
<TargetName>usart-spi</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>32000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>1</RunSim>
<RunTarget>0</RunTarget>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\lst\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<DllOpt>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments>-MPU</SimDllArguments>
<SimDlgDllName>DCM.DLL</SimDlgDllName>
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments>-MPU</TargetDllArguments>
<TargetDlgDllName>TCM.DLL</TargetDlgDllName>
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
</DllOpt>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>0</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<nTsel>7</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>Segger\JL2CM3.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U4294967295 -O78 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8008 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TRE0 -FO7 -FD20000000 -FC800 -FN1 -FF0EFM32 -FS00 -FL020000</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<DebugFlag>
<trace>0</trace>
<periodic>0</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
</TargetOption>
</Target>
<Group>
<GroupName>CMSIS</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\Device\EnergyMicro\EFM32G\Source\ARM\startup_efm32g.s</PathWithFileName>
<FilenameWithoutPath>startup_efm32g.s</FilenameWithoutPath>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\Device\EnergyMicro\EFM32G\Source\system_efm32g.c</PathWithFileName>
<FilenameWithoutPath>system_efm32g.c</FilenameWithoutPath>
</File>
</Group>
<Group>
<GroupName>emlib</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\emlib\src\em_system.c</PathWithFileName>
<FilenameWithoutPath>em_system.c</FilenameWithoutPath>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\emlib\src\em_emu.c</PathWithFileName>
<FilenameWithoutPath>em_emu.c</FilenameWithoutPath>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\emlib\src\em_cmu.c</PathWithFileName>
<FilenameWithoutPath>em_cmu.c</FilenameWithoutPath>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\emlib\src\em_gpio.c</PathWithFileName>
<FilenameWithoutPath>em_gpio.c</FilenameWithoutPath>
</File>
</Group>
<Group>
<GroupName>Source</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\main_spi.c</PathWithFileName>
<FilenameWithoutPath>main_spi.c</FilenameWithoutPath>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\spi.c</PathWithFileName>
<FilenameWithoutPath>spi.c</FilenameWithoutPath>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>9</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\usart.c</PathWithFileName>
<FilenameWithoutPath>usart.c</FilenameWithoutPath>
</File>
</Group>
<WinLayoutEx>
</WinLayoutEx>
</ProjectOpt>
This diff is collapsed.
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
DEVICE = EFM32GG330F1024
PROJECTNAME = simple_efm32_usart-spi
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.7 2012q4
LINUXCS ?= /usr
RMDIRS := rm -rf
RMFILES := rm -rf
ALLFILES := /*.*
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RMDIRS := rd /s /q
RMFILES := del /s /q
ALLFILES := \*.*
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RMFILES) $(OBJ_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(EXE_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(LST_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb \
-mfix-cortex-m3-ldrd -ffunction-sections \
-fdata-sections -fomit-frame-pointer \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../../../common/Device/EnergyMicro/EFM32GG/Source/GCC/efm32gg.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../../../common/CMSIS/Include \
-I../../../common/Device/EnergyMicro/EFM32GG/Include \
-I../../../common/emlib/inc \
-I../../../common/kits
####################################################################
# Files #
####################################################################
C_SRC += \
../../../common/Device/EnergyMicro/EFM32GG/Source/system_efm32gg.c \
../../../common/emlib/src/em_system.c \
../../../common/emlib/src/em_emu.c \
../../../common/emlib/src/em_cmu.c \
../../../common/emlib/src/em_gpio.c \
../main_spi.c \
../spi.c \
../usart.c
s_SRC +=
S_SRC += \
../../../common/Device/EnergyMicro/EFM32GG/Source/GCC/startup_efm32gg.S
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RMDIRS) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>usart-spi</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/usart-spi/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>Include_Dependencies/cmsis_CMSIS_Include</name>
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/CMSIS/Include</locationURI>
</link>
<link>
<name>Include_Dependencies/cmsis_Device_EnergyMicro_EFM32G_Include</name>
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/Device/EnergyMicro/EFM32G/Include</locationURI>
</link>
<link>
<name>Include_Dependencies/cmsis_emlib_inc</name>
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/emlib/inc</locationURI>
</link>
<link>
<name>Include_Dependencies/kitconfig</name>
<type>2</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/kits</locationURI>
</link>
<link>
<name>csdata</name>
<type>2</type>
<locationURI>PROJECT_LOC/.csdata</locationURI>
</link>
<link>
<name>CMSIS/startup_efm32g.s</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/Device/EnergyMicro/EFM32G/Source/Atollic/startup_efm32g.s</locationURI>
</link>
<link>
<name>CMSIS/system_efm32g.c</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/Device/EnergyMicro/EFM32G/Source/system_efm32g.c</locationURI>
</link>
<link>
<name>emlib/em_system.c</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/emlib/src/em_system.c</locationURI>
</link>
<link>
<name>emlib/em_emu.c</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/emlib/src/em_emu.c</locationURI>
</link>
<link>
<name>emlib/em_cmu.c</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/emlib/src/em_cmu.c</locationURI>
</link>
<link>
<name>emlib/em_gpio.c</name>
<type>1</type>
<locationURI>$%7BPARENT-4-PROJECT_LOC%7D/emlib/src/em_gpio.c</locationURI>
</link>
<link>
<name>Source/main_spi.c</name>
<type>1</type>
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/main_spi.c</locationURI>
</link>
<link>
<name>Source/spi.c</name>
<type>1</type>
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/spi.c</locationURI>
</link>
<link>
<name>Source/usart.c</name>
<type>1</type>
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/usart.c</locationURI>
</link>
</linkedResources>
<filteredResources>
<filter>
<name>Include_Dependencies/cmsis_CMSIS_Include</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.h</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/cmsis_CMSIS_Include</name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/cmsis_Device_EnergyMicro_EFM32G_Include</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.h</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/cmsis_Device_EnergyMicro_EFM32G_Include</name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/cmsis_emlib_inc</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.h</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/cmsis_emlib_inc</name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/kitconfig</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.h</arguments>
</matcher>
</filter>
<filter>
<name>Include_Dependencies/kitconfig</name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
#Fri Oct 19 20:28:11 CEST 2012
BOARD=None
CODE_LOCATION=FLASH
ENDIAN=Little-endian
MCU=EFM32G890F128
MCU_VENDOR=Energy Micro
MODEL=Pro
PROJECT_FORMAT_VERSION=2
TARGET=ARM\u00AE
VERSION=3.1.0
eclipse.preferences.version=1
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
DEVICE = EFM32G890F128
PROJECTNAME = usart-spi
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to CodeSourcery tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI
LINUXCS ?= /cad/codesourcery/arm-none-eabi/cs-lite
RM := rm -rf
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RM := "$(TOOLDIR)/bin/cs-rm" -rf
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RM) $(OBJ_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(EXE_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(LST_DIR)/*>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -ffunction-sections \
-fdata-sections -mfix-cortex-m3-ldrd -fomit-frame-pointer \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../../../Device/EnergyMicro/EFM32G/Source/G++/efm32g.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lcs3 -lcs3unhosted -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../../../CMSIS/Include \
-I../../../Device/EnergyMicro/EFM32G/Include \
-I../../../emlib/inc \
-I../../../kits
####################################################################
# Files #
####################################################################
C_SRC += \
../../../Device/EnergyMicro/EFM32G/Source/system_efm32g.c \
../../../emlib/src/em_system.c \
../../../emlib/src/em_emu.c \
../../../emlib/src/em_cmu.c \
../../../emlib/src/em_gpio.c \
../main_spi.c \
../spi.c \
../usart.c
s_SRC += \
../../../Device/EnergyMicro/EFM32G/Source/G++/startup_efm32g.s
S_SRC +=
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RM) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
This diff is collapsed.
This diff is collapsed.
<?xml version ="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\usart-spi.ewp</path>
</project>
<batchBuild/>
</workspace>
/******************************************************************************
* @file
* @brief SPI Demo Application
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#include <string.h>
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "spi.h"
#include "usart.h"
/* Buffers */
char transmitBuffer[] = "Energy Micro";
#define BUFFERSIZE (sizeof(transmitBuffer) / sizeof(char))
char receiveBuffer[BUFFERSIZE];
char receiveBuffer2[BUFFERSIZE];
/******************************************************************************
* @brief initializing spi settings
*
*****************************************************************************/
void init(void)
{
/* Enabling clock to USART 1 and 2*/
CMU_ClockEnable(cmuClock_USART1, true);
CMU_ClockEnable(cmuClock_USART2, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* Setup UART */
SPI_setup(USART1_NUM, GPIO_POS1, false);
SPI_setup(USART2_NUM, GPIO_POS0, true);
}
/******************************************************************************
* @brief Main function
* Main is called from _program_start, see assembly startup file
*****************************************************************************/
int main(void)
{
/* Initialize chip */
CHIP_Init();
/* Initalizing */
init();
/* Data transmission to slave */
/* ************************** */
/*Setting up both RX and TX interrupts for slave */
SPI1_setupSlaveInt(receiveBuffer2, BUFFERSIZE, NO_TX, NO_TX);
/* Setting up RX interrupt for master */
SPI2_setupRXInt(NO_RX, NO_RX);
/* Transmitting data */
USART2_sendBuffer(transmitBuffer, BUFFERSIZE);
/* Data reception from slave */
/* ************************** */
/*Setting up both RX and TX interrupts for slave */
SPI1_setupSlaveInt(NO_RX, NO_RX, transmitBuffer, BUFFERSIZE);
/* Setting up RX interrupt for master */
SPI2_setupRXInt(receiveBuffer, BUFFERSIZE);
/* Receiving data by transmitting dummy data to slave */
USART2_sendBuffer(NO_TX, BUFFERSIZE);
/* Clearing the receive buffers */
memset(receiveBuffer, '\0', BUFFERSIZE);
memset(receiveBuffer2, '\0', BUFFERSIZE);
/* Transmitting data both ways simultanously */
/* ***************************************** */
/*Setting up both RX and TX interrupts for slave */
SPI1_setupSlaveInt(receiveBuffer2, BUFFERSIZE, transmitBuffer, BUFFERSIZE);
/* Setting up RX interrupt for master */
SPI2_setupRXInt(receiveBuffer, BUFFERSIZE);
/* Receiving data by transmitting dummy data to slave */
USART2_sendBuffer(transmitBuffer, BUFFERSIZE);
while (1) ;
}
Thank you for downloading / using this application note.
The project in this application note expects certain resources to be available at
specific locations in the folder hierachy. Please make sure to install this
application note at the correct place, normally (Simplicity Studio paths):
For win7:
C:\Users\'USERNAME'\AppData\Roaming\energymicro\an
For winXP:
C:\Documents and Settings\'USERNAME'\Application Data\energymicro\an
The resulting path for a given application note will be:
....\energymicro\an\<application_note_name>
The surrounding hierarchy must be as follows:
root_folder (e.g. C:\Documents and Settings\'USERNAME'\Application Data\energymicro\)
|
-->an
| |
| --> <application_note_name>
|
-->CMSIS
|
|
-->efm32lib
|
|
-->kits
The other resources can be obtained through Simplicity Studio
or downloaded from the Energy Micro webpage:
http://www.energymicro.com/downloads/software
<!DOCTYPE CrossStudio_Project_File>
<solution Name="usart-spi" version="2">
<project Name="usart-spi">
<configuration Name="Common" Target="EFM32G890F128" arm_architecture="v7M" arm_core_type="Cortex-M3" arm_gcc_target="arm-unknown-eabi" arm_linker_heap_size="128" arm_linker_process_stack_size="0" arm_linker_stack_size="1024" arm_simulator_memory_simulation_filename="$(TargetsDir)/EFM32/EFM32SimulatorMemory.dll" arm_simulator_memory_simulation_parameter="EFM32G890F128;FLASH=0x00000000:0x20000;RAM=0x20000000:0x4000" arm_target_debug_interface_type="ADIv5" arm_target_flash_loader_file_path="$(TargetsDir)/EFM32/Release/Loader_rpc.elf" arm_target_loader_parameter="14318180" c_preprocessor_definitions="USE_PROCESS_STACK;STARTUP_FROM_RESET" c_user_include_directories="$(ProjectDir)/..;$(ProjectDir)/../../../CMSIS/Include;$(ProjectDir)/../../../Device/EnergyMicro/EFM32G/Include;$(ProjectDir)/../../../emlib/inc;$(ProjectDir)/../../../kits" link_include_startup_code="No" linker_additional_files="$(TargetsDir)/EFM32/lib/libefm32$(LibExt)$(LIB)" linker_memory_map_file="$(TargetsDir)/EFM32/EFM32G890F128_MemoryMap.xml" linker_output_format="bin" linker_printf_fmt_level="long" linker_printf_width_precision_supported="Yes" oscillator_frequency="14.31818MHz" project_directory="" project_type="Executable" property_groups_file_path="$(TargetsDir)/EFM32/EFM32_propertyGroups.xml"/>
<configuration Name="Flash" Placement="Flash" arm_target_flash_loader_file_path="$(TargetsDir)/EFM32/Release/Loader_rpc.elf" arm_target_flash_loader_type="LIBMEM RPC Loader" linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml" target_reset_script="FLASHReset()"/>
<configuration Name="RAM" Placement="RAM" linker_section_placement_file="$(StudioDir)/targets/Cortex_M/ram_placement.xml" target_reset_script="SRAMReset()"/>
<folder Name="CMSIS">
<file file_name="../../../Device/EnergyMicro/EFM32G/Source/system_efm32g.c"/>
</folder>
<folder Name="emlib">
<file file_name="../../../emlib/src/em_system.c"/>
<file file_name="../../../emlib/src/em_emu.c"/>
<file file_name="../../../emlib/src/em_cmu.c"/>
<file file_name="../../../emlib/src/em_gpio.c"/>
</folder>
<folder Name="Source">
<file file_name="../main_spi.c"/>
<file file_name="../spi.c"/>
<file file_name="../usart.c"/>
</folder>
<folder Name="System Files">
<file file_name="$(StudioDir)/source/thumb_crt0.s"/>
<file file_name="$(TargetsDir)/EFM32/EFM32_Startup.s"/>
<file file_name="$(TargetsDir)/EFM32/EFM32_Target.js">
<configuration Name="Common" file_type="Reset Script"/>
</file>
</folder>
</project>
<configuration Name="THUMB Flash Debug" inherited_configurations="THUMB;Flash;Debug"/>
<configuration Name="THUMB Flash Release" inherited_configurations="THUMB;Flash;Release"/>
<configuration Name="THUMB" Platform="ARM" arm_instruction_set="THUMB" arm_library_instruction_set="THUMB" c_preprocessor_definitions="__THUMB" hidden="Yes"/>
<configuration Name="Flash" c_preprocessor_definitions="__FLASH_BUILD" hidden="Yes"/>
<configuration Name="Debug" build_debug_information="Yes" c_additional_options="-Wall;-Wextra;" c_preprocessor_definitions="DEBUG;" gcc_optimization_level="None" hidden="Yes" link_include_startup_code="No"/>
<configuration Name="Release" build_debug_information="No" c_additional_options="-Wall;-Wextra;" c_preprocessor_definitions="" gcc_optimization_level="None" hidden="Yes" link_include_startup_code="No"/>
<configuration Name="Common" linker_printf_enabled="Yes"/>
</solution>
This diff is collapsed.
/**************************************************************************//**
* @file
* @brief SPI prototypes and definitions
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __SPI_H
#define __SPI_H
#include <stdbool.h>
#include "em_device.h"
void SPI_setup(uint8_t spiNumber, uint8_t location, bool master);
void SPI2_setupRXInt(char* receiveBuffer, int bytesToReceive);
void SPI1_setupSlaveInt(char* receiveBuffer, int receiveBufferSize, char* transmitBuffer, int transmitBufferSize);
#endif
/**************************************************************************//**
* @file
* @brief SPI Example Header File
*
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __SPI_PROJECT_H
#define __SPI_PROJECT_H
/* Defines */
#define HFRCO_FREQUENCY 14000000
#define SPI_PERCLK_FREQUENCY HFRCO_FREQUENCY
#define SPI_BAUDRATE 1000000
#endif
/**************************************************************************//**
* @file
* @brief USART example
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#include "em_device.h"
#include "usart.h"
#include "em_gpio.h"
/******************************************************************************
* @brief sends data using USART2
* @param txBuffer points to data to transmit
* @param bytesToSend bytes will be sent
*****************************************************************************/
void USART2_sendBuffer(char* txBuffer, int bytesToSend)
{
USART_TypeDef *uart = USART2;
int ii;
/* Sending the data */
for (ii = 0; ii < bytesToSend; ii++)
{
/* Waiting for the usart to be ready */
while (!(uart->STATUS & USART_STATUS_TXBL)) ;
if (txBuffer != 0)
{
/* Writing next byte to USART */
uart->TXDATA = *txBuffer;
txBuffer++;
}
else
{
uart->TXDATA = 0;
}
}
/*Waiting for transmission of last byte */
while (!(uart->STATUS & USART_STATUS_TXC)) ;
}
/**************************************************************************//**
* @file
* @brief USART prototypes and definitions
* @author Energy Micro AS
* @version 1.12
******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __USART_H
#define __USART_H
#include <stdbool.h>
#include "em_device.h"
#define NO_RX 0
#define NO_TX NO_RX
#define USART0_NUM 0
#define USART1_NUM 1
#define USART2_NUM 2
#define GPIO_POS0 0
#define GPIO_POS1 1
#define GPIO_POS2 2
void USART2_sendBuffer(char*, int);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment