From 0752e9d7e973161c32e4b667c7a8d06c68b0a9eb Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 9 Aug 2011 10:07:11 +0000 Subject: I2C. Syncing with trunk (step 1) git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3214 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 testhal/STM32F1xx/I2C/tmp75.c (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c new file mode 100644 index 000000000..72e634527 --- /dev/null +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -0,0 +1,52 @@ +/** + * TMP75 is most simple I2C device in our case. It is already useful with + * default settings after powerup. + * You only must read 2 sequential bytes from it. + */ + +#include + +#include "ch.h" +#include "hal.h" + +#include "tmp75.h" + + +/* input buffer */ +static i2cblock_t tmp75_rx_data[TMP75_RX_DEPTH]; + +/* temperature value */ +static int16_t temperature = 0; + +/* Simple error trap */ +static void i2c_tmp75_error_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ + (void)i2cscfg; + int status = 0; + status = i2cp->id_i2c->SR1; + while(TRUE); +} + +/* This callback raise up when transfer finished */ +static void i2c_tmp75_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ + (void)*i2cp; + (void)*i2cscfg; + /* store temperature value */ +} + +/* Fill TMP75 config. */ +static const I2CSlaveConfig tmp75 = { + i2c_tmp75_cb, + i2c_tmp75_error_cb, +}; + +#define tmp75_addr 0b1001000 + +/* This is main function. */ +void request_temperature(void){ + i2cAcquireBus(&I2CD2); + i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, 2); + i2cReleaseBus(&I2CD2); + temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1]; +} + + -- cgit v1.2.3 From 1253ee88be70e16fe9057b5e1727f8664fa0c4ae Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 6 Dec 2011 09:09:53 +0000 Subject: I2C. Testhal changed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3558 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 52 ------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 testhal/STM32F1xx/I2C/tmp75.c (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c deleted file mode 100644 index 72e634527..000000000 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ /dev/null @@ -1,52 +0,0 @@ -/** - * TMP75 is most simple I2C device in our case. It is already useful with - * default settings after powerup. - * You only must read 2 sequential bytes from it. - */ - -#include - -#include "ch.h" -#include "hal.h" - -#include "tmp75.h" - - -/* input buffer */ -static i2cblock_t tmp75_rx_data[TMP75_RX_DEPTH]; - -/* temperature value */ -static int16_t temperature = 0; - -/* Simple error trap */ -static void i2c_tmp75_error_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ - (void)i2cscfg; - int status = 0; - status = i2cp->id_i2c->SR1; - while(TRUE); -} - -/* This callback raise up when transfer finished */ -static void i2c_tmp75_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ - (void)*i2cp; - (void)*i2cscfg; - /* store temperature value */ -} - -/* Fill TMP75 config. */ -static const I2CSlaveConfig tmp75 = { - i2c_tmp75_cb, - i2c_tmp75_error_cb, -}; - -#define tmp75_addr 0b1001000 - -/* This is main function. */ -void request_temperature(void){ - i2cAcquireBus(&I2CD2); - i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, 2); - i2cReleaseBus(&I2CD2); - temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1]; -} - - -- cgit v1.2.3 From 2fbafd292a430fef8a16bc0c8cbe53e1a6a53bd0 Mon Sep 17 00:00:00 2001 From: barthess Date: Wed, 7 Dec 2011 19:26:30 +0000 Subject: I2C. Testhal updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3573 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 testhal/STM32F1xx/I2C/tmp75.c (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c new file mode 100644 index 000000000..7acc8c668 --- /dev/null +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -0,0 +1,37 @@ +/** + * TMP75 is most simple I2C device in our case. It is already useful with + * default settings after powerup. + * You only must read 2 sequential bytes from it. + */ + +#include + +#include "ch.h" +#include "hal.h" + +#include "tmp75.h" + + +/* input buffer */ +static uint8_t tmp75_rx_data[TMP75_RX_DEPTH]; + +/* temperature value */ +static int16_t temperature = 0; + + +#define tmp75_addr 0b1001000 + +/* This is main function. */ +void request_temperature(void){ + int16_t t_int = 0, t_frac = 0; + + i2cAcquireBus(&I2CD1); + i2cMasterReceive(&I2CD1, tmp75_addr, tmp75_rx_data, 2); + i2cReleaseBus(&I2CD1); + + t_int = tmp75_rx_data[0] * 100; + t_frac = (tmp75_rx_data[1] * 100) >> 8; + temperature = t_int + t_frac; +} + + -- cgit v1.2.3 From f1d3f298955eec396bcc1e791f3e6fbbb6c4c3e0 Mon Sep 17 00:00:00 2001 From: barthess Date: Wed, 7 Dec 2011 20:15:19 +0000 Subject: I2C. F1x testhal clean ups. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3575 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index 7acc8c668..630a76dac 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -1,3 +1,23 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + /** * TMP75 is most simple I2C device in our case. It is already useful with * default settings after powerup. -- cgit v1.2.3 From 8196de6aef7616f7df96d757dddc9cfa9eb661dc Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 8 Dec 2011 19:28:55 +0000 Subject: I2C. Testhal update. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3584 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index 630a76dac..23410843f 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -38,6 +38,7 @@ static uint8_t tmp75_rx_data[TMP75_RX_DEPTH]; /* temperature value */ static int16_t temperature = 0; +static i2cflags_t errors = 0; #define tmp75_addr 0b1001000 @@ -46,7 +47,7 @@ void request_temperature(void){ int16_t t_int = 0, t_frac = 0; i2cAcquireBus(&I2CD1); - i2cMasterReceive(&I2CD1, tmp75_addr, tmp75_rx_data, 2); + i2cMasterReceive(&I2CD1, tmp75_addr, tmp75_rx_data, 2, &errors, TIME_INFINITE); i2cReleaseBus(&I2CD1); t_int = tmp75_rx_data[0] * 100; -- cgit v1.2.3 From 2234fd3e31d4ce6e2b3990340b52719951e65731 Mon Sep 17 00:00:00 2001 From: barthess Date: Fri, 30 Dec 2011 20:45:56 +0000 Subject: I2C. API changes mostly done. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3692 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index 23410843f..9d41e0a0f 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -45,11 +45,17 @@ static i2cflags_t errors = 0; /* This is main function. */ void request_temperature(void){ int16_t t_int = 0, t_frac = 0; + msg_t status = RDY_OK; + systime_t tmo = MS2ST(4); i2cAcquireBus(&I2CD1); - i2cMasterReceive(&I2CD1, tmp75_addr, tmp75_rx_data, 2, &errors, TIME_INFINITE); + status = i2cMasterReceiveTimeout(&I2CD1, tmp75_addr, tmp75_rx_data, 2, tmo); i2cReleaseBus(&I2CD1); + if (status != RDY_OK){ + errors = i2cGetErrors(&I2CD1); + } + t_int = tmp75_rx_data[0] * 100; t_frac = (tmp75_rx_data[1] * 100) >> 8; temperature = t_int + t_frac; -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index 9d41e0a0f..db9a43edf 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index db9a43edf..7b78603ff 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 853216256ad4cdacf5f94edb7d6b738c6be165a1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Mar 2013 10:32:37 +0000 Subject: Relicensing parts of the tree under the Apache 2.0 license. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5521 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F1xx/I2C/tmp75.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'testhal/STM32F1xx/I2C/tmp75.c') diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c index 7b78603ff..478c322fa 100644 --- a/testhal/STM32F1xx/I2C/tmp75.c +++ b/testhal/STM32F1xx/I2C/tmp75.c @@ -1,21 +1,17 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - This file is part of ChibiOS/RT. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + http://www.apache.org/licenses/LICENSE-2.0 - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ /** -- cgit v1.2.3