From 7cff54195a868c63afdfa0b9742f8f25813a0b20 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Fri, 10 Aug 2012 23:16:36 +0300 Subject: [PATCH 01/16] set the unique CatNip product ID again --- projectconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projectconfig.h b/projectconfig.h index b0bf5be..7656509 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -617,8 +617,8 @@ CDC (see 'puts' in systeminit.c). -----------------------------------------------------------------------*/ - #define CFG_USB_VID (0x239A) - #define CFG_USB_PID (0x1002) + #define CFG_USB_VID (0x1d50) + #define CFG_USB_PID (0x600c) #ifdef CFG_BRD_LPC1343_REFDESIGN // #define CFG_USBHID From 0a9cbe719aa8fbcb99aa8482fcf715abaf522493 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 16 Oct 2012 19:56:27 +0200 Subject: [PATCH 02/16] fixed reversed bit on gpio pin interrupt edge setup --- core/gpio/gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/gpio/gpio.c b/core/gpio/gpio.c index fe80dbc..2f03e9a 100644 --- a/core/gpio/gpio.c +++ b/core/gpio/gpio.c @@ -306,7 +306,7 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s *gpiois |= (0x1< Date: Tue, 16 Oct 2012 20:00:54 +0200 Subject: [PATCH 03/16] added macro to set interrupt priority --- lpc134x.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lpc134x.h b/lpc134x.h index 002f7cd..237b27c 100644 --- a/lpc134x.h +++ b/lpc134x.h @@ -2019,6 +2019,12 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn) NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); } +static inline void NVIC_SetIRQPriority(IRQn_t IRQn, uint8_t priority) +{ + NVIC->IP[(uint32_t)(IRQn)] = ((priority << 5) & 0xff); /* set Priority for device specific Interrupts */ +} + + /*############################################################################## ## GPIO - General Purpose I/O ##############################################################################*/ From a93cde1fdf6b38acbf30c0271bab83afedda9b4e Mon Sep 17 00:00:00 2001 From: Miceuz Date: Fri, 26 Oct 2012 17:12:49 +0200 Subject: [PATCH 04/16] add ds18b20 to make file, fix typo --- Makefile | 3 +++ drivers/sensors/ds18b20/ds18b20.c | 2 +- drivers/sensors/ds18b20/ds18b20.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 34cc96c..530a3a5 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ OBJS += eeprom.o mcp24aa.o VPATH += drivers/sensors/lm75b OBJS += lm75b.o +VPATH += drivers/sensors/ds18b20 +OBJS += ds18b20.o + # ISL12022M RTC VPATH += drivers/rtc/isl12022m OBJS += isl12022m.o diff --git a/drivers/sensors/ds18b20/ds18b20.c b/drivers/sensors/ds18b20/ds18b20.c index e4e4da2..e3ee53d 100644 --- a/drivers/sensors/ds18b20/ds18b20.c +++ b/drivers/sensors/ds18b20/ds18b20.c @@ -180,7 +180,7 @@ void ds18b20Init(uint32_t portNumber, uint32_t bitPosition, volatile uint32_t *i @note Reading is returned mutiplied by 10000 i.e. for 25.8750 degrees the result will be 258750 */ -uint32_t ds18b20GetTemparature(){ +uint32_t ds18b20GetTemperature(){ //Reset, skip ROM and start temperature conversion if(reset()) { printf("DS18B20 is not responding%s", CFG_PRINTF_NEWLINE); diff --git a/drivers/sensors/ds18b20/ds18b20.h b/drivers/sensors/ds18b20/ds18b20.h index 85640d4..974d51d 100644 --- a/drivers/sensors/ds18b20/ds18b20.h +++ b/drivers/sensors/ds18b20/ds18b20.h @@ -44,7 +44,7 @@ void ds18b20Init(uint32_t portNum, uint32_t bitPos, volatile uint32_t *ioconReg); -uint32_t ds18b20GetTemparature(); +uint32_t ds18b20GetTemperature(); #endif From 42266fc4c3ac51fe69d941667c122ba94ff7112f Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 16 Oct 2012 20:00:54 +0200 Subject: [PATCH 05/16] ignore *.i *.s --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 32d5a23..6e29dbd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ *.hex *.elf *.ld +*.i +*.s lpcrc From d84f011ddfb29f073f6b6b8013a3801901fc37a6 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Sat, 13 Oct 2012 16:54:36 +0200 Subject: [PATCH 06/16] adc CLI command (cherry picked from commit a8821b8801633610d389bf25231f39e03efde0ae) --- Makefile | 1 + project/cmd_tbl.h | 4 +- project/commands/cmd_adc.c | 78 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 project/commands/cmd_adc.c diff --git a/Makefile b/Makefile index 530a3a5..ed009c0 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o OBJS += cmd_roundedcorner.o cmd_pwm.o +OBJS += cmd_adc.o VPATH += project/commands/drawing OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index 83d3880..7460582 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -97,6 +97,8 @@ void cmd_sd_dir(uint8_t argc, char **argv); void cmd_pwm(uint8_t argc, char **argv); #endif +void cmd_adc_read(uint8_t argc, char **argv); + #define CMD_NOPARAMS "This command has no parameters" /**************************************************************************/ @@ -114,7 +116,7 @@ cmd_t cmd_tbl[] = { "?", 0, 0, 0, cmd_help , "Help" , CMD_NOPARAMS }, { "V", 0, 0, 0, cmd_sysinfo , "System Info" , CMD_NOPARAMS }, { "Z", 0, 0, 0, cmd_reset , "Reset" , CMD_NOPARAMS }, - + { "adc", 1, 2, 0, cmd_adc_read , "ADC read" , "adc " }, #ifdef CFG_I2CEEPROM { "e", 1, 1, 0, cmd_i2ceeprom_read , "EEPROM Read" , "'e '" }, { "w", 2, 2, 0, cmd_i2ceeprom_write , "EEPROM Write" , "'w '" }, diff --git a/project/commands/cmd_adc.c b/project/commands/cmd_adc.c new file mode 100644 index 0000000..828dce7 --- /dev/null +++ b/project/commands/cmd_adc.c @@ -0,0 +1,78 @@ +/**************************************************************************/ +/*! + @file cmd_sysinfo.c + @author Miceuz + + @brief Code to execute for cmd_sysinfo in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2012, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#include "core/adc/adc.h" + +/**************************************************************************/ +/*! + PWM command handler +*/ +/**************************************************************************/ + +void cmd_adc_read(uint8_t argc, char **argv) { + int32_t channel = 0; + int32_t numReads = 1; + + getNumber (argv[0], &channel); + if(channel < 0) + { + printf("Invalid duty channel, only channels [0..2] avalable%s", CFG_PRINTF_NEWLINE); + return; + } + + if(argc > 1) { + getNumber (argv[1], &numReads); + if(numReads < 1) + { + printf("Invalid number of reads [1..65535]%s", CFG_PRINTF_NEWLINE); + return; + } + } + adcInit(); + int i = 0; + for(i = 0; i < numReads; i++) { + uint32_t result = adcReadSingle(channel); + printf("%d%s", (uint16_t)result, CFG_PRINTF_NEWLINE); + } +} \ No newline at end of file From 88114b3847163fa4c3abaf782904efb87663da2a Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 11:46:34 +0100 Subject: [PATCH 07/16] fix some typos and text --- project/commands/cmd_adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project/commands/cmd_adc.c b/project/commands/cmd_adc.c index 828dce7..082064a 100644 --- a/project/commands/cmd_adc.c +++ b/project/commands/cmd_adc.c @@ -1,6 +1,6 @@ /**************************************************************************/ /*! - @file cmd_sysinfo.c + @file cmd_adc.c @author Miceuz @brief Code to execute for cmd_sysinfo in the 'core/cmd' @@ -46,7 +46,7 @@ /**************************************************************************/ /*! - PWM command handler + ADC command handler */ /**************************************************************************/ @@ -55,9 +55,9 @@ void cmd_adc_read(uint8_t argc, char **argv) { int32_t numReads = 1; getNumber (argv[0], &channel); - if(channel < 0) + if(channel < 0 || channel > 2) { - printf("Invalid duty channel, only channels [0..2] avalable%s", CFG_PRINTF_NEWLINE); + printf("Invalid ADC channel, only channels [0..2] are avalable%s", CFG_PRINTF_NEWLINE); return; } From 99d07745a94b64df0a9d6302bc9f58b26bd17d37 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Sat, 13 Oct 2012 16:54:36 +0200 Subject: [PATCH 08/16] adc CLI command (cherry picked from commit a8821b8801633610d389bf25231f39e03efde0ae) (cherry picked from commit d84f011ddfb29f073f6b6b8013a3801901fc37a6) --- Makefile | 1 + project/cmd_tbl.h | 4 +- project/commands/cmd_adc.c | 78 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 project/commands/cmd_adc.c diff --git a/Makefile b/Makefile index 34cc96c..c158c99 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o OBJS += cmd_roundedcorner.o cmd_pwm.o +OBJS += cmd_adc.o VPATH += project/commands/drawing OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index 83d3880..7460582 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -97,6 +97,8 @@ void cmd_sd_dir(uint8_t argc, char **argv); void cmd_pwm(uint8_t argc, char **argv); #endif +void cmd_adc_read(uint8_t argc, char **argv); + #define CMD_NOPARAMS "This command has no parameters" /**************************************************************************/ @@ -114,7 +116,7 @@ cmd_t cmd_tbl[] = { "?", 0, 0, 0, cmd_help , "Help" , CMD_NOPARAMS }, { "V", 0, 0, 0, cmd_sysinfo , "System Info" , CMD_NOPARAMS }, { "Z", 0, 0, 0, cmd_reset , "Reset" , CMD_NOPARAMS }, - + { "adc", 1, 2, 0, cmd_adc_read , "ADC read" , "adc " }, #ifdef CFG_I2CEEPROM { "e", 1, 1, 0, cmd_i2ceeprom_read , "EEPROM Read" , "'e '" }, { "w", 2, 2, 0, cmd_i2ceeprom_write , "EEPROM Write" , "'w '" }, diff --git a/project/commands/cmd_adc.c b/project/commands/cmd_adc.c new file mode 100644 index 0000000..828dce7 --- /dev/null +++ b/project/commands/cmd_adc.c @@ -0,0 +1,78 @@ +/**************************************************************************/ +/*! + @file cmd_sysinfo.c + @author Miceuz + + @brief Code to execute for cmd_sysinfo in the 'core/cmd' + command-line interpretter. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2012, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#include "core/adc/adc.h" + +/**************************************************************************/ +/*! + PWM command handler +*/ +/**************************************************************************/ + +void cmd_adc_read(uint8_t argc, char **argv) { + int32_t channel = 0; + int32_t numReads = 1; + + getNumber (argv[0], &channel); + if(channel < 0) + { + printf("Invalid duty channel, only channels [0..2] avalable%s", CFG_PRINTF_NEWLINE); + return; + } + + if(argc > 1) { + getNumber (argv[1], &numReads); + if(numReads < 1) + { + printf("Invalid number of reads [1..65535]%s", CFG_PRINTF_NEWLINE); + return; + } + } + adcInit(); + int i = 0; + for(i = 0; i < numReads; i++) { + uint32_t result = adcReadSingle(channel); + printf("%d%s", (uint16_t)result, CFG_PRINTF_NEWLINE); + } +} \ No newline at end of file From 27289c82548fc870d77494f2f8092d862e2174ea Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 11:46:34 +0100 Subject: [PATCH 09/16] fix some typos and text (cherry picked from commit 88114b3847163fa4c3abaf782904efb87663da2a) --- project/commands/cmd_adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project/commands/cmd_adc.c b/project/commands/cmd_adc.c index 828dce7..082064a 100644 --- a/project/commands/cmd_adc.c +++ b/project/commands/cmd_adc.c @@ -1,6 +1,6 @@ /**************************************************************************/ /*! - @file cmd_sysinfo.c + @file cmd_adc.c @author Miceuz @brief Code to execute for cmd_sysinfo in the 'core/cmd' @@ -46,7 +46,7 @@ /**************************************************************************/ /*! - PWM command handler + ADC command handler */ /**************************************************************************/ @@ -55,9 +55,9 @@ void cmd_adc_read(uint8_t argc, char **argv) { int32_t numReads = 1; getNumber (argv[0], &channel); - if(channel < 0) + if(channel < 0 || channel > 2) { - printf("Invalid duty channel, only channels [0..2] avalable%s", CFG_PRINTF_NEWLINE); + printf("Invalid ADC channel, only channels [0..2] are avalable%s", CFG_PRINTF_NEWLINE); return; } From f04530b6fd09826a2bd63d77c73ca55e1d1d955b Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 12:39:47 +0100 Subject: [PATCH 10/16] add CatNip board as an option to projectconfig.h --- projectconfig.h | 138 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 129 insertions(+), 9 deletions(-) diff --git a/projectconfig.h b/projectconfig.h index 7656509..2ca6cae 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -120,14 +120,21 @@ LPC1343 LPCXpresso board + CFG_BRD_LPC1343_CATNIP + ============================== + + LPC1343 CatNip board + + -----------------------------------------------------------------------*/ - #define CFG_BRD_LPC1343_REFDESIGN + // #define CFG_BRD_LPC1343_REFDESIGN // #define CFG_BRD_LPC1343_REFDESIGN_MINIMAL // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK // #define CFG_BRD_LPC1343_OLIMEX_P // #define CFG_BRD_LPC1343_LPCXPRESSO + #define CFG_BRD_LPC1343_CATNIP /*=========================================================================*/ @@ -314,6 +321,14 @@ // #define GPIO_ENABLE_IRQ2 // #define GPIO_ENABLE_IRQ3 #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define GPIO_ENABLE_IRQ0 + #define GPIO_ENABLE_IRQ1 + // #define GPIO_ENABLE_IRQ2 + // #define GPIO_ENABLE_IRQ3 + #endif + /*=========================================================================*/ @@ -384,6 +399,12 @@ #define CFG_UART_BAUDRATE (115200) #define CFG_UART_BUFSIZE (512) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_UART_BAUDRATE (115200) + #define CFG_UART_BUFSIZE (512) + #endif + /*=========================================================================*/ @@ -393,6 +414,7 @@ CFG_SSP0_SCKPIN_2_11 Indicates which pin should be used for SCK0 CFG_SSP0_SCKPIN_0_6 + CFG_SSP0_SCKPIN_0_10 -----------------------------------------------------------------------*/ #ifdef CFG_BRD_LPC1343_REFDESIGN @@ -424,6 +446,12 @@ #define CFG_SSP0_SCKPIN_2_11 // #define CFG_SSP0_SCKPIN_0_6 #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_SSP0_SCKPIN_0_10 + #endif + + /*=========================================================================*/ @@ -471,6 +499,12 @@ #define ADC_AVERAGING_ENABLE (0) #define ADC_AVERAGING_SAMPLES (5) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define ADC_AVERAGING_ENABLE (0) + #define ADC_AVERAGING_SAMPLES (5) + #endif + /*=========================================================================*/ @@ -525,6 +559,14 @@ #define CFG_LED_ON (0) #define CFG_LED_OFF (1) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_LED_PORT (2) + #define CFG_LED_PIN (10) + #define CFG_LED_ON (0) + #define CFG_LED_OFF (1) + #endif + /*=========================================================================*/ @@ -593,6 +635,14 @@ #define CFG_SDCARD_CDPORT (3) #define CFG_SDCARD_CDPIN (0) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_SDCARD + #define CFG_SDCARD_READONLY (1) // Must be 0 or 1 + #define CFG_SDCARD_CDPORT (3) + #define CFG_SDCARD_CDPIN (0) + #endif + /*=========================================================================*/ @@ -617,9 +667,15 @@ CDC (see 'puts' in systeminit.c). -----------------------------------------------------------------------*/ - #define CFG_USB_VID (0x1d50) - #define CFG_USB_PID (0x600c) - + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_USB_VID (0x1d50) + #define CFG_USB_PID (0x600c) + #else + #define CFG_USB_VID (0x239A) + #define CFG_USB_PID (0x1002) + #endif + #ifdef CFG_BRD_LPC1343_REFDESIGN // #define CFG_USBHID #define CFG_USBCDC @@ -675,6 +731,15 @@ #define CFG_USBCDC_INITTIMEOUT (5000) #define CFG_USBCDC_BUFFERSIZE (256) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_USBHID + #define CFG_USBCDC + #define CFG_USBCDC_BAUDRATE (115200) + #define CFG_USBCDC_INITTIMEOUT (5000) + #define CFG_USBCDC_BUFFERSIZE (256) + #endif + /*=========================================================================*/ @@ -741,6 +806,14 @@ #define CFG_PRINTF_USBCDC #define CFG_PRINTF_NEWLINE "\r\n" #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_PRINTF_MAXSTRINGSIZE (255) + // #define CFG_PRINTF_UART + #define CFG_PRINTF_USBCDC + #define CFG_PRINTF_NEWLINE "\r\n" + #endif + /*=========================================================================*/ @@ -902,6 +975,21 @@ #define CFG_INTERFACE_CONFIRMREADY (0) #define CFG_INTERFACE_LONGSYSINFO (0) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_INTERFACE + #define CFG_INTERFACE_MAXMSGSIZE (256) + #define CFG_INTERFACE_PROMPT "CatNip >> " + #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (0) + #define CFG_INTERFACE_ENABLEIRQ (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) + #define CFG_INTERFACE_LONGSYSINFO (0) + #endif + /*=========================================================================*/ @@ -926,6 +1014,9 @@ // #define CFG_PWM #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) #define CFG_PWM_DEFAULT_DUTYCYCLE (50) + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_PWM + #endif /*=========================================================================*/ @@ -982,6 +1073,12 @@ // #define CFG_I2CEEPROM #define CFG_I2CEEPROM_SIZE (3072) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_I2CEEPROM + #define CFG_I2CEEPROM_SIZE (3072) + #endif + /*=========================================================================*/ @@ -1131,6 +1228,17 @@ #define CFG_CHIBI_PROMISCUOUS (0) #define CFG_CHIBI_BUFFERSIZE (128) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_CHIBI + #define CFG_CHIBI_MODE (0) // OQPSK_868MHZ + #define CFG_CHIBI_POWER (0xE9) // CHB_PWR_EU2_3DBM + #define CFG_CHIBI_CHANNEL (0) // 868-868.6 MHz + #define CFG_CHIBI_PANID (0x1234) + #define CFG_CHIBI_PROMISCUOUS (0) + #define CFG_CHIBI_BUFFERSIZE (128) + #endif + /*=========================================================================*/ @@ -1220,6 +1328,15 @@ #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) #define CFG_TFTLCD_TS_KEYPADDELAY (100) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_TFTLCD + #define CFG_TFTLCD_INCLUDESMALLFONTS (0) + #define CFG_TFTLCD_USEAAFONTS (0) + #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) + #define CFG_TFTLCD_TS_KEYPADDELAY (100) + #endif + /*=========================================================================*/ @@ -1284,8 +1401,9 @@ !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && \ !defined CFG_BRD_LPC1343_802154USBSTICK && \ !defined CFG_BRD_LPC1343_OLIMEX_P && \ - !defined CFG_BRD_LPC1343_LPCXPRESSO - #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK or CFG_BRD_LPC1343_LPCXPRESSO)" + !defined CFG_BRD_LPC1343_LPCXPRESSO && \ + !defined CFG_BRD_LPC1343_CATNIP + #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK or CFG_BRD_LPC1343_LPCXPRESSO or CFG_BRD_LPC1343_CATNIP)" #endif #if defined CFG_PRINTF_USBCDC && defined CFG_PRINTF_UART @@ -1300,12 +1418,14 @@ #error "Only one USB class can be defined at a time (CFG_USBCDC or CFG_USBHID)" #endif -#if defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_6 +#if defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_6 || \ + defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_10 || \ + defined CFG_SSP0_SCKPIN_0_6 && defined CFG_SSP0_SCKPIN_0_10 #error "Only one SCK pin can be defined at a time for SSP0" #endif -#if !defined CFG_SSP0_SCKPIN_2_11 && !defined CFG_SSP0_SCKPIN_0_6 - #error "An SCK pin must be selected for SSP0 (CFG_SSP0_SCKPIN_2_11 or CFG_SSP0_SCKPIN_0_6)" +#if !defined CFG_SSP0_SCKPIN_2_11 && !defined CFG_SSP0_SCKPIN_0_6 && !defined CFG_SSP0_SCKPIN_0_10 + #error "An SCK pin must be selected for SSP0 (CFG_SSP0_SCKPIN_2_11 or CFG_SSP0_SCKPIN_0_6 or CFG_SSP0_SCKPIN_0_10)" #endif #ifdef CFG_INTERFACE From d2975676d1b9c4585d33b1022c09f1f92e9c5b21 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 13:07:03 +0100 Subject: [PATCH 11/16] add CFG_SSP0_SCKPIN_0_10 option to ssp core driver --- core/ssp/ssp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/ssp/ssp.c b/core/ssp/ssp.c index e1f31e2..3d1ef05 100644 --- a/core/ssp/ssp.c +++ b/core/ssp/ssp.c @@ -172,6 +172,12 @@ void sspInit (uint8_t portNum, sspClockPolarity_t polarity, sspClockPhase_t phas IOCON_PIO0_6 = IOCON_PIO0_6_FUNC_SCK; #endif + /* Set 0.6 to SSP SCK (2.11 and 0.10 can also be used) */ + #ifdef CFG_SSP0_SCKPIN_0_10 + IOCON_SCKLOC = IOCON_SCKLOC_SCKPIN_PIO0_10; + IOCON_JTAG_TCK_PIO0_10 = IOCON_JTAG_TCK_PIO0_10_FUNC_SCK; + #endif + /* Set P0.2/SSEL to GPIO output and high */ IOCON_PIO0_2 &= ~IOCON_PIO0_2_FUNC_MASK; IOCON_PIO0_2 |= IOCON_PIO0_2_FUNC_GPIO; From a8f1a8df9902af85bfb4bceaa8db9307a6f235dd Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 13:08:26 +0100 Subject: [PATCH 12/16] add SSP command to CLI --- Makefile | 2 +- project/cmd_tbl.h | 3 ++ project/commands/cmd_ssp.c | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 project/commands/cmd_ssp.c diff --git a/Makefile b/Makefile index ed009c0..751b017 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o OBJS += cmd_roundedcorner.o cmd_pwm.o -OBJS += cmd_adc.o +OBJS += cmd_adc.o cmd_ssp.o VPATH += project/commands/drawing OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index 7460582..323c3a9 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -99,6 +99,8 @@ void cmd_pwm(uint8_t argc, char **argv); void cmd_adc_read(uint8_t argc, char **argv); +void cmd_ssp_write(uint8_t argc, char **argv); + #define CMD_NOPARAMS "This command has no parameters" /**************************************************************************/ @@ -163,6 +165,7 @@ cmd_t cmd_tbl[] = #ifdef CFG_PWM { "M", 2, 2, 0, cmd_pwm , "PWM Control" , "'M [] []'" }, #endif + { "ssp", 1, 1, 0, cmd_ssp_write , "Write a byte to SSP" , "'ssp '"} }; #endif \ No newline at end of file diff --git a/project/commands/cmd_ssp.c b/project/commands/cmd_ssp.c new file mode 100644 index 0000000..2252d6a --- /dev/null +++ b/project/commands/cmd_ssp.c @@ -0,0 +1,65 @@ +/**************************************************************************/ +/*! + @file cmd_ssp.c + @author Miceuz + + @brief SSP CLI command. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2012, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#include "core/ssp/ssp.h" + +/**************************************************************************/ +/*! + SSP command handler +*/ +/**************************************************************************/ + +void cmd_ssp_write(uint8_t argc, char **argv) { + int32_t value = 0; + uint8_t request[SSP_FIFOSIZE]; + + getNumber (argv[0], &value); + + request[0]=(uint8_t) value; + + + sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge); + ssp0Select(); + sspSend(0, (uint8_t *)&request, 1); + ssp0Deselect(); +} \ No newline at end of file From b02908cbc19f4aa956d2cfbbdab77fdaf667bad4 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 12:39:47 +0100 Subject: [PATCH 13/16] add CatNip board as an option to projectconfig.h --- projectconfig.h | 138 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 129 insertions(+), 9 deletions(-) diff --git a/projectconfig.h b/projectconfig.h index 7656509..2ca6cae 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -120,14 +120,21 @@ LPC1343 LPCXpresso board + CFG_BRD_LPC1343_CATNIP + ============================== + + LPC1343 CatNip board + + -----------------------------------------------------------------------*/ - #define CFG_BRD_LPC1343_REFDESIGN + // #define CFG_BRD_LPC1343_REFDESIGN // #define CFG_BRD_LPC1343_REFDESIGN_MINIMAL // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK // #define CFG_BRD_LPC1343_OLIMEX_P // #define CFG_BRD_LPC1343_LPCXPRESSO + #define CFG_BRD_LPC1343_CATNIP /*=========================================================================*/ @@ -314,6 +321,14 @@ // #define GPIO_ENABLE_IRQ2 // #define GPIO_ENABLE_IRQ3 #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define GPIO_ENABLE_IRQ0 + #define GPIO_ENABLE_IRQ1 + // #define GPIO_ENABLE_IRQ2 + // #define GPIO_ENABLE_IRQ3 + #endif + /*=========================================================================*/ @@ -384,6 +399,12 @@ #define CFG_UART_BAUDRATE (115200) #define CFG_UART_BUFSIZE (512) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_UART_BAUDRATE (115200) + #define CFG_UART_BUFSIZE (512) + #endif + /*=========================================================================*/ @@ -393,6 +414,7 @@ CFG_SSP0_SCKPIN_2_11 Indicates which pin should be used for SCK0 CFG_SSP0_SCKPIN_0_6 + CFG_SSP0_SCKPIN_0_10 -----------------------------------------------------------------------*/ #ifdef CFG_BRD_LPC1343_REFDESIGN @@ -424,6 +446,12 @@ #define CFG_SSP0_SCKPIN_2_11 // #define CFG_SSP0_SCKPIN_0_6 #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_SSP0_SCKPIN_0_10 + #endif + + /*=========================================================================*/ @@ -471,6 +499,12 @@ #define ADC_AVERAGING_ENABLE (0) #define ADC_AVERAGING_SAMPLES (5) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define ADC_AVERAGING_ENABLE (0) + #define ADC_AVERAGING_SAMPLES (5) + #endif + /*=========================================================================*/ @@ -525,6 +559,14 @@ #define CFG_LED_ON (0) #define CFG_LED_OFF (1) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_LED_PORT (2) + #define CFG_LED_PIN (10) + #define CFG_LED_ON (0) + #define CFG_LED_OFF (1) + #endif + /*=========================================================================*/ @@ -593,6 +635,14 @@ #define CFG_SDCARD_CDPORT (3) #define CFG_SDCARD_CDPIN (0) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_SDCARD + #define CFG_SDCARD_READONLY (1) // Must be 0 or 1 + #define CFG_SDCARD_CDPORT (3) + #define CFG_SDCARD_CDPIN (0) + #endif + /*=========================================================================*/ @@ -617,9 +667,15 @@ CDC (see 'puts' in systeminit.c). -----------------------------------------------------------------------*/ - #define CFG_USB_VID (0x1d50) - #define CFG_USB_PID (0x600c) - + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_USB_VID (0x1d50) + #define CFG_USB_PID (0x600c) + #else + #define CFG_USB_VID (0x239A) + #define CFG_USB_PID (0x1002) + #endif + #ifdef CFG_BRD_LPC1343_REFDESIGN // #define CFG_USBHID #define CFG_USBCDC @@ -675,6 +731,15 @@ #define CFG_USBCDC_INITTIMEOUT (5000) #define CFG_USBCDC_BUFFERSIZE (256) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_USBHID + #define CFG_USBCDC + #define CFG_USBCDC_BAUDRATE (115200) + #define CFG_USBCDC_INITTIMEOUT (5000) + #define CFG_USBCDC_BUFFERSIZE (256) + #endif + /*=========================================================================*/ @@ -741,6 +806,14 @@ #define CFG_PRINTF_USBCDC #define CFG_PRINTF_NEWLINE "\r\n" #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_PRINTF_MAXSTRINGSIZE (255) + // #define CFG_PRINTF_UART + #define CFG_PRINTF_USBCDC + #define CFG_PRINTF_NEWLINE "\r\n" + #endif + /*=========================================================================*/ @@ -902,6 +975,21 @@ #define CFG_INTERFACE_CONFIRMREADY (0) #define CFG_INTERFACE_LONGSYSINFO (0) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_INTERFACE + #define CFG_INTERFACE_MAXMSGSIZE (256) + #define CFG_INTERFACE_PROMPT "CatNip >> " + #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (0) + #define CFG_INTERFACE_ENABLEIRQ (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) + #define CFG_INTERFACE_LONGSYSINFO (0) + #endif + /*=========================================================================*/ @@ -926,6 +1014,9 @@ // #define CFG_PWM #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) #define CFG_PWM_DEFAULT_DUTYCYCLE (50) + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_PWM + #endif /*=========================================================================*/ @@ -982,6 +1073,12 @@ // #define CFG_I2CEEPROM #define CFG_I2CEEPROM_SIZE (3072) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + #define CFG_I2CEEPROM + #define CFG_I2CEEPROM_SIZE (3072) + #endif + /*=========================================================================*/ @@ -1131,6 +1228,17 @@ #define CFG_CHIBI_PROMISCUOUS (0) #define CFG_CHIBI_BUFFERSIZE (128) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_CHIBI + #define CFG_CHIBI_MODE (0) // OQPSK_868MHZ + #define CFG_CHIBI_POWER (0xE9) // CHB_PWR_EU2_3DBM + #define CFG_CHIBI_CHANNEL (0) // 868-868.6 MHz + #define CFG_CHIBI_PANID (0x1234) + #define CFG_CHIBI_PROMISCUOUS (0) + #define CFG_CHIBI_BUFFERSIZE (128) + #endif + /*=========================================================================*/ @@ -1220,6 +1328,15 @@ #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) #define CFG_TFTLCD_TS_KEYPADDELAY (100) #endif + + #ifdef CFG_BRD_LPC1343_CATNIP + // #define CFG_TFTLCD + #define CFG_TFTLCD_INCLUDESMALLFONTS (0) + #define CFG_TFTLCD_USEAAFONTS (0) + #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) + #define CFG_TFTLCD_TS_KEYPADDELAY (100) + #endif + /*=========================================================================*/ @@ -1284,8 +1401,9 @@ !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && \ !defined CFG_BRD_LPC1343_802154USBSTICK && \ !defined CFG_BRD_LPC1343_OLIMEX_P && \ - !defined CFG_BRD_LPC1343_LPCXPRESSO - #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK or CFG_BRD_LPC1343_LPCXPRESSO)" + !defined CFG_BRD_LPC1343_LPCXPRESSO && \ + !defined CFG_BRD_LPC1343_CATNIP + #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK or CFG_BRD_LPC1343_LPCXPRESSO or CFG_BRD_LPC1343_CATNIP)" #endif #if defined CFG_PRINTF_USBCDC && defined CFG_PRINTF_UART @@ -1300,12 +1418,14 @@ #error "Only one USB class can be defined at a time (CFG_USBCDC or CFG_USBHID)" #endif -#if defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_6 +#if defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_6 || \ + defined CFG_SSP0_SCKPIN_2_11 && defined CFG_SSP0_SCKPIN_0_10 || \ + defined CFG_SSP0_SCKPIN_0_6 && defined CFG_SSP0_SCKPIN_0_10 #error "Only one SCK pin can be defined at a time for SSP0" #endif -#if !defined CFG_SSP0_SCKPIN_2_11 && !defined CFG_SSP0_SCKPIN_0_6 - #error "An SCK pin must be selected for SSP0 (CFG_SSP0_SCKPIN_2_11 or CFG_SSP0_SCKPIN_0_6)" +#if !defined CFG_SSP0_SCKPIN_2_11 && !defined CFG_SSP0_SCKPIN_0_6 && !defined CFG_SSP0_SCKPIN_0_10 + #error "An SCK pin must be selected for SSP0 (CFG_SSP0_SCKPIN_2_11 or CFG_SSP0_SCKPIN_0_6 or CFG_SSP0_SCKPIN_0_10)" #endif #ifdef CFG_INTERFACE From aec78f844c6fb21c38e69f002366d04ca53c88e6 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 13:07:03 +0100 Subject: [PATCH 14/16] add CFG_SSP0_SCKPIN_0_10 option to ssp core driver --- core/ssp/ssp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/ssp/ssp.c b/core/ssp/ssp.c index e1f31e2..3d1ef05 100644 --- a/core/ssp/ssp.c +++ b/core/ssp/ssp.c @@ -172,6 +172,12 @@ void sspInit (uint8_t portNum, sspClockPolarity_t polarity, sspClockPhase_t phas IOCON_PIO0_6 = IOCON_PIO0_6_FUNC_SCK; #endif + /* Set 0.6 to SSP SCK (2.11 and 0.10 can also be used) */ + #ifdef CFG_SSP0_SCKPIN_0_10 + IOCON_SCKLOC = IOCON_SCKLOC_SCKPIN_PIO0_10; + IOCON_JTAG_TCK_PIO0_10 = IOCON_JTAG_TCK_PIO0_10_FUNC_SCK; + #endif + /* Set P0.2/SSEL to GPIO output and high */ IOCON_PIO0_2 &= ~IOCON_PIO0_2_FUNC_MASK; IOCON_PIO0_2 |= IOCON_PIO0_2_FUNC_GPIO; From 9abb77a63575bcbd0a808744aaa7f259e30e708b Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 13:08:26 +0100 Subject: [PATCH 15/16] add SSP command to CLI --- Makefile | 2 +- project/cmd_tbl.h | 3 ++ project/commands/cmd_ssp.c | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 project/commands/cmd_ssp.c diff --git a/Makefile b/Makefile index c158c99..40c8a63 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o OBJS += cmd_roundedcorner.o cmd_pwm.o -OBJS += cmd_adc.o +OBJS += cmd_adc.o cmd_ssp.o VPATH += project/commands/drawing OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index 7460582..323c3a9 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -99,6 +99,8 @@ void cmd_pwm(uint8_t argc, char **argv); void cmd_adc_read(uint8_t argc, char **argv); +void cmd_ssp_write(uint8_t argc, char **argv); + #define CMD_NOPARAMS "This command has no parameters" /**************************************************************************/ @@ -163,6 +165,7 @@ cmd_t cmd_tbl[] = #ifdef CFG_PWM { "M", 2, 2, 0, cmd_pwm , "PWM Control" , "'M [] []'" }, #endif + { "ssp", 1, 1, 0, cmd_ssp_write , "Write a byte to SSP" , "'ssp '"} }; #endif \ No newline at end of file diff --git a/project/commands/cmd_ssp.c b/project/commands/cmd_ssp.c new file mode 100644 index 0000000..2252d6a --- /dev/null +++ b/project/commands/cmd_ssp.c @@ -0,0 +1,65 @@ +/**************************************************************************/ +/*! + @file cmd_ssp.c + @author Miceuz + + @brief SSP CLI command. + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2012, microBuilder SARL + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#include + +#include "projectconfig.h" +#include "core/cmd/cmd.h" +#include "project/commands.h" // Generic helper functions + +#include "core/ssp/ssp.h" + +/**************************************************************************/ +/*! + SSP command handler +*/ +/**************************************************************************/ + +void cmd_ssp_write(uint8_t argc, char **argv) { + int32_t value = 0; + uint8_t request[SSP_FIFOSIZE]; + + getNumber (argv[0], &value); + + request[0]=(uint8_t) value; + + + sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge); + ssp0Select(); + sspSend(0, (uint8_t *)&request, 1); + ssp0Deselect(); +} \ No newline at end of file From f6f6730151b98acba35a59e2707f8aff72e20739 Mon Sep 17 00:00:00 2001 From: Miceuz Date: Tue, 19 Feb 2013 13:12:29 +0100 Subject: [PATCH 16/16] make LPC1343_REFDESIGN default --- projectconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projectconfig.h b/projectconfig.h index 2ca6cae..7f95ac5 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -127,14 +127,14 @@ -----------------------------------------------------------------------*/ - // #define CFG_BRD_LPC1343_REFDESIGN + #define CFG_BRD_LPC1343_REFDESIGN // #define CFG_BRD_LPC1343_REFDESIGN_MINIMAL // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK // #define CFG_BRD_LPC1343_OLIMEX_P // #define CFG_BRD_LPC1343_LPCXPRESSO - #define CFG_BRD_LPC1343_CATNIP + // #define CFG_BRD_LPC1343_CATNIP /*=========================================================================*/