aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorbarthess <barthess@yandex.ru>2016-01-24 20:41:06 +0300
committerbarthess <barthess@yandex.ru>2016-01-24 20:41:06 +0300
commit956134d0bae1f34088b222c63d22e3ae7c9ad4cf (patch)
tree1ee3c06dfcb2946349847eb8e47dc476c56f1e22 /os/hal/include
parentd43271e5bcea206de8b99fffb61d0cdfc939994f (diff)
downloadChibiOS-Contrib-956134d0bae1f34088b222c63d22e3ae7c9ad4cf.tar.gz
ChibiOS-Contrib-956134d0bae1f34088b222c63d22e3ae7c9ad4cf.tar.bz2
ChibiOS-Contrib-956134d0bae1f34088b222c63d22e3ae7c9ad4cf.zip
1-wire driver improvements.
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/onewire.h41
1 files changed, 29 insertions, 12 deletions
diff --git a/os/hal/include/onewire.h b/os/hal/include/onewire.h
index a2760e6..f9a0c4d 100644
--- a/os/hal/include/onewire.h
+++ b/os/hal/include/onewire.h
@@ -46,6 +46,16 @@
#define ONEWIRE_CMD_CONVERT_TEMP 0x44
#define ONEWIRE_CMD_READ_SCRATCHPAD 0xBE
+/**
+ * @brief How many bits will be used for transaction length storage.
+ */
+#define ONEWIRE_REG_BYTES_WIDTH 16U
+
+/**
+ * @brief Precalculated maximum transaction length.
+ */
+#define ONEWIRE_MAX_TRANSACTION_LEN ((1U << ONEWIRE_REG_BYTES_WIDTH) - 1U)
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
@@ -116,6 +126,20 @@ typedef struct {
* @brief Pointer to @p PWM driver used for communication.
*/
PWMDriver *pwmd;
+ /**
+ * @brief Pointer to configuration structure for underlying PWM driver.
+ * @note It is NOT constant because 1-wire driver needs to change them
+ * during normal functioning.
+ */
+ PWMConfig *pwmcfg;
+ /**
+ * @brief Active logic level for master channel.
+ * @details Just set it to @p PWM_OUTPUT_ACTIVE_LOW when 1-wire bus
+ * connected to direct (not complementary) output of the timer.
+ * In opposite case you need to check documentation to choose
+ * correct value.
+ */
+ pwmmode_t pwmmode;
/**
* @brief Number of PWM channel used as master pulse generator.
*/
@@ -167,7 +191,7 @@ typedef struct {
*/
typedef struct {
/**
- * @brief Bool flag. If @p true than only bus has only one slave device.
+ * @brief Bool flag. True when bus has single slave device.
*/
uint32_t single_device: 1;
/**
@@ -260,7 +284,7 @@ typedef struct {
/**
* @brief Bytes number to be processing in current transaction.
*/
- uint32_t bytes: 16;
+ uint32_t bytes: ONEWIRE_REG_BYTES_WIDTH;
} onewire_reg_t;
/**
@@ -276,10 +300,6 @@ typedef struct {
*/
const onewireConfig *config;
/**
- * @brief Config for underlying PWM driver.
- */
- PWMConfig pwmcfg;
- /**
* @brief Pointer to I/O data buffer.
*/
uint8_t *buf;
@@ -315,14 +335,11 @@ extern "C" {
bool onewireReset(onewireDriver *owp);
void onewireRead(onewireDriver *owp, uint8_t *rxbuf, size_t rxbytes);
uint8_t onewireCRC(const uint8_t *buf, size_t len);
- void onewireWrite(onewireDriver *owp,
- uint8_t *txbuf,
- size_t txbytes,
- systime_t pullup_time);
+ void onewireWrite(onewireDriver *owp, uint8_t *txbuf,
+ size_t txbytes, systime_t pullup_time);
#if ONEWIRE_USE_SEARCH_ROM
size_t onewireSearchRom(onewireDriver *owp,
- uint8_t *result,
- size_t max_rom_cnt);
+ uint8_t *result, size_t max_rom_cnt);
#endif /* ONEWIRE_USE_SEARCH_ROM */
#if ONEWIRE_SYNTH_SEARCH_TEST
void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit);