You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/01/08 19:13:33 UTC

[GitHub] brolan-juul commented on a change in pull request #1590: Adding Flash Write Functionality

brolan-juul commented on a change in pull request #1590: Adding Flash Write Functionality
URL: https://github.com/apache/mynewt-core/pull/1590#discussion_r246117827
 
 

 ##########
 File path: hw/drivers/bq27z561/src/bq27z561.c
 ##########
 @@ -587,6 +587,104 @@ bq27x561_rd_flash(struct bq27z561 *dev, uint16_t addr, uint8_t *buf, int buflen)
     return ret;
 }
 
+bq27z561_err_t
+bq27z561_wr_flash(struct bq27z561 *dev, uint16_t addr, uint8_t *buf, int buflen)
+{
+    uint8_t tmpbuf[BQ27Z561_MAX_FLASH_RW_LEN + 2];
+    uint8_t chksum;
+    bq27z561_err_t ret;
+    int rc;
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+    struct os_dev *odev = &dev->dev.dev;
+#else
+    struct hal_i2c_master_data i2c;
+#endif
+
+    if ((buflen == 0) || (!buf) || (buflen > BQ27Z561_MAX_FLASH_RW_LEN)) {
+        return BQ27Z561_ERR_INV_PARAMS;
+    }
+
+    if ((addr < BQ27Z561_FLASH_BEG_ADDR) || (addr > BQ27Z561_FLASH_END_ADDR)) {
 
 Review comment:
   It's a bit unclear to me how this out of bounds check was originally intended to work. BQ27Z561_FLASH_END_ADDR ends at 0x4600. The last flash data register is located at 0x4526 with a register length of a byte.
   
   Based on this information, we should never be out of bounds unless our buflen is large.
   
   I'm happy putting this in there but I think the intended effect will be negligible.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services