n-Blocks-HALL / RM25C512C-L_driver
Revision:
2:183d1d96f917
Parent:
1:67d99e4ce310
Child:
3:e846980a1536
--- a/rm25c512cl.cpp	Wed Sep 12 12:14:39 2018 +0000
+++ b/rm25c512cl.cpp	Wed Sep 12 14:48:05 2018 +0000
@@ -83,12 +83,13 @@
 * @details  Writes multiple bytes to the specified address given.
 * @param    Starting address to write to.
 * @param    Pointer to the data array containg bytes to be stored.
+* @param    Size of the data array in bytes.
 * @return   NA
 * @warning  A page write(128 bytes) can take up to 5 ms to complete
 * 
 */
 
-void rm25c512cl :: write_bytes(uint16_t address, char* data){
+void rm25c512cl :: write_bytes(uint16_t address, char* data, uint16_t data_size){
     
     char cmd[3];
     char data_buffer[1];// not used here but required for spi.write() as a parameter
@@ -104,7 +105,7 @@
     _cs = 0;   
     
     _spi.write(&cmd[0],3,&data_buffer[0],0);
-    _spi.write(&data[0],sizeof(data),&data_buffer[0],0);
+    _spi.write(&data[0],data_size,&data_buffer[0],0);
   
     _cs = 1;
     
@@ -151,15 +152,16 @@
 
 /**
 * @brief    read_bytes()
-* @details  Reads page of data(128 bytes) at given address.
+* @details  Reads multiple bytes at given address.
 * @param    Page Address to start reading from.
-* @param    Pointer to data buffer to store multiple bytes read from EEprom
+* @param    Pointer to data buffer to store multiple bytes read from EEprom.
+* @param    Size of the data buffer in bytes.
 * @return   
 * @warning  Data buffer must be of size 128 bytes to read entire page.
 * 
 */
 
-void rm25c512cl :: read_bytes(uint16_t address, char* data_buffer){
+void rm25c512cl :: read_bytes(uint16_t address, char* data_buffer, uint16_t data_buffer_size){
     
     char cmd[3];
    
@@ -177,7 +179,7 @@
     
     cmd[0] = 0xFF;
         
-    _spi.write(&cmd[0],1,&data_buffer[0],sizeof(data_buffer));
+    _spi.write(&cmd[0],1,&data_buffer[0],data_buffer_size);
       
     _cs = 1;