Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several fixes and new features #14

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
*.hex
*.elf
*.ld
*.i
*.s
lpcrc
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 cmd_ssp.o

VPATH += project/commands/drawing
OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o
Expand All @@ -64,6 +65,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
Expand Down
6 changes: 6 additions & 0 deletions core/ssp/ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensors/ds18b20/ds18b20.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensors/ds18b20/ds18b20.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


void ds18b20Init(uint32_t portNum, uint32_t bitPos, volatile uint32_t *ioconReg);
uint32_t ds18b20GetTemparature();
uint32_t ds18b20GetTemperature();
#endif


6 changes: 6 additions & 0 deletions lpc134x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
##############################################################################*/
Expand Down
7 changes: 6 additions & 1 deletion project/cmd_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ 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);

void cmd_ssp_write(uint8_t argc, char **argv);

#define CMD_NOPARAMS "This command has no parameters"

/**************************************************************************/
Expand All @@ -114,7 +118,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 <channel> <num reads>" },
#ifdef CFG_I2CEEPROM
{ "e", 1, 1, 0, cmd_i2ceeprom_read , "EEPROM Read" , "'e <addr>'" },
{ "w", 2, 2, 0, cmd_i2ceeprom_write , "EEPROM Write" , "'w <addr> <val>'" },
Expand Down Expand Up @@ -161,6 +165,7 @@ cmd_t cmd_tbl[] =
#ifdef CFG_PWM
{ "M", 2, 2, 0, cmd_pwm , "PWM Control" , "'M [<dutycycle(%)>] [<frequency(ticks)>]'" },
#endif
{ "ssp", 1, 1, 0, cmd_ssp_write , "Write a byte to SSP" , "'ssp <byte>'"}
};

#endif
78 changes: 78 additions & 0 deletions project/commands/cmd_adc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**************************************************************************/
/*!
@file cmd_adc.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 <stdio.h>

#include "projectconfig.h"
#include "core/cmd/cmd.h"
#include "project/commands.h" // Generic helper functions

#include "core/adc/adc.h"

/**************************************************************************/
/*!
ADC 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 || channel > 2)
{
printf("Invalid ADC channel, only channels [0..2] are 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);
}
}
65 changes: 65 additions & 0 deletions project/commands/cmd_ssp.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

#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();
}
Loading