commit
099b1f94a3
@ -81,7 +81,11 @@
|
||||
#define WRITE_TX0 0x00
|
||||
#define WRITE_TX1 0xFF
|
||||
|
||||
#define PIN_OPENDRAIN(GPIO) ((GPIO) | GPIO_OPENDRAIN)
|
||||
#define PIN_OPENDRAIN(GPIO) ((GPIO) | GPIO_CNF_OUTOD)
|
||||
|
||||
#if defined(CONFIG_STM32_STM32F10XX)
|
||||
# define USART_CR3_ONEBIT (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -568,13 +572,13 @@ static void stm32_1wire_set_apb_clock(struct stm32_1wire_priv_s *priv,
|
||||
regaddr = STM32_RCC_APB1ENR;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_UART4
|
||||
#ifdef CONFIG_STM32_UART4_1WIREDRIVER
|
||||
case STM32_UART4_BASE:
|
||||
rcc_en = RCC_APB1ENR_UART4EN;
|
||||
regaddr = STM32_RCC_APB1ENR;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_UART5
|
||||
#ifdef CONFIG_STM32_UART5_1WIREDRIVER
|
||||
case STM32_UART5_BASE:
|
||||
rcc_en = RCC_APB1ENR_UART5EN;
|
||||
regaddr = STM32_RCC_APB1ENR;
|
||||
@ -586,13 +590,13 @@ static void stm32_1wire_set_apb_clock(struct stm32_1wire_priv_s *priv,
|
||||
regaddr = STM32_RCC_APB2ENR;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_UART7
|
||||
#ifdef CONFIG_STM32_UART7_1WIREDRIVER
|
||||
case STM32_UART7_BASE:
|
||||
rcc_en = RCC_APB1ENR_UART7EN;
|
||||
regaddr = STM32_RCC_APB1ENR;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_UART8
|
||||
#ifdef CONFIG_STM32_UART8_1WIREDRIVER
|
||||
case STM32_UART8_BASE:
|
||||
rcc_en = RCC_APB1ENR_UART8EN;
|
||||
regaddr = STM32_RCC_APB1ENR;
|
||||
|
@ -313,7 +313,7 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
||||
addr -= STM32_FLASH_BASE;
|
||||
}
|
||||
|
||||
if ((addr+count) >= STM32_FLASH_SIZE)
|
||||
if ((addr+count) > STM32_FLASH_SIZE)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
@ -139,6 +139,10 @@
|
||||
# define CONFIG_AT24XX_MTD_BLOCKSIZE AT24XX_PAGESIZE
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_AT24XX_TIMEOUT_MS
|
||||
# define CONFIG_AT24XX_TIMEOUT_MS 10
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Types
|
||||
************************************************************************************/
|
||||
@ -252,6 +256,7 @@ static int at24c_eraseall(FAR struct at24c_dev_s *priv)
|
||||
{
|
||||
uint8_t buf[AT24XX_PAGESIZE + AT24XX_ADDRSIZE];
|
||||
int startblock = 0;
|
||||
uint16_t wait;
|
||||
|
||||
memset(&buf[AT24XX_ADDRSIZE], 0xff, priv->pagesize);
|
||||
|
||||
@ -269,8 +274,14 @@ static int at24c_eraseall(FAR struct at24c_dev_s *priv)
|
||||
at24addr = (priv->addr | ((offset >> 8) & 0x07));
|
||||
#endif
|
||||
|
||||
wait = CONFIG_AT24XX_TIMEOUT_MS;
|
||||
while (at24c_i2c_write(priv, at24addr, buf, AT24XX_ADDRSIZE) < 0)
|
||||
{
|
||||
finfo("wait\n");
|
||||
if (!wait--)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
@ -301,6 +312,7 @@ static ssize_t at24c_read_internal(FAR struct at24c_dev_s *priv, off_t offset,
|
||||
{
|
||||
uint8_t buf[AT24XX_ADDRSIZE];
|
||||
uint16_t at24addr;
|
||||
uint16_t wait;
|
||||
|
||||
finfo("offset: %lu nbytes: %lu address: %02x\n",
|
||||
(unsigned long)offset, (unsigned long)nbytes, address);
|
||||
@ -327,9 +339,14 @@ static ssize_t at24c_read_internal(FAR struct at24c_dev_s *priv, off_t offset,
|
||||
at24addr = (address | ((offset >> 8) & 0x07));
|
||||
#endif
|
||||
|
||||
wait = CONFIG_AT24XX_TIMEOUT_MS;
|
||||
while (at24c_i2c_write(priv, at24addr, buf, AT24XX_ADDRSIZE) < 0)
|
||||
{
|
||||
finfo("wait\n");
|
||||
if (!wait--)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
@ -410,6 +427,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
FAR struct at24c_dev_s *priv = (FAR struct at24c_dev_s *)dev;
|
||||
size_t blocksleft;
|
||||
uint8_t buf[AT24XX_PAGESIZE + AT24XX_ADDRSIZE];
|
||||
uint16_t wait;
|
||||
|
||||
#if CONFIG_AT24XX_MTD_BLOCKSIZE > AT24XX_PAGESIZE
|
||||
startblock *= (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
@ -443,9 +461,14 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
at24addr = (priv->addr | ((offset >> 8) & 0x07));
|
||||
#endif
|
||||
|
||||
wait = CONFIG_AT24XX_TIMEOUT_MS;
|
||||
while (at24c_i2c_write(priv, at24addr, buf, AT24XX_ADDRSIZE) < 0)
|
||||
{
|
||||
finfo("wait\n");
|
||||
if (!wait--)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user