|
@@ -85,8 +85,16 @@ int spi_read ( struct nvs_device *nvs, unsigned int address,
|
85
|
85
|
struct spi_bus *bus = device->bus;
|
86
|
86
|
unsigned int command = spi_command ( SPI_READ, address,
|
87
|
87
|
device->munge_address );
|
|
88
|
+ int rc;
|
|
89
|
+
|
|
90
|
+ DBG ( "SPI %p reading %d bytes from %#04x\n", device, len, address );
|
|
91
|
+ if ( ( rc = bus->rw ( bus, device, command, address,
|
|
92
|
+ NULL, data, len ) ) != 0 ) {
|
|
93
|
+ DBG ( "SPI %p failed to read data from device\n", device );
|
|
94
|
+ return rc;
|
|
95
|
+ }
|
88
|
96
|
|
89
|
|
- return bus->rw ( bus, device, command, address, NULL, data, len );
|
|
97
|
+ return 0;
|
90
|
98
|
}
|
91
|
99
|
|
92
|
100
|
/**
|
|
@@ -106,16 +114,24 @@ int spi_write ( struct nvs_device *nvs, unsigned int address,
|
106
|
114
|
device->munge_address );
|
107
|
115
|
int rc;
|
108
|
116
|
|
|
117
|
+ DBG ( "SPI %p writing %d bytes to %#04x\n", device, len, address );
|
|
118
|
+
|
109
|
119
|
if ( ( rc = bus->rw ( bus, device, SPI_WREN, -1,
|
110
|
|
- NULL, NULL, 0 ) ) != 0 )
|
|
120
|
+ NULL, NULL, 0 ) ) != 0 ) {
|
|
121
|
+ DBG ( "SPI %p failed to write-enable device\n", device );
|
111
|
122
|
return rc;
|
|
123
|
+ }
|
112
|
124
|
|
113
|
125
|
if ( ( rc = bus->rw ( bus, device, command, address,
|
114
|
|
- data, NULL, len ) ) != 0 )
|
|
126
|
+ data, NULL, len ) ) != 0 ) {
|
|
127
|
+ DBG ( "SPI %p failed to write data to device\n", device );
|
115
|
128
|
return rc;
|
|
129
|
+ }
|
116
|
130
|
|
117
|
|
- if ( ( rc = spi_wait ( device ) ) != 0 )
|
|
131
|
+ if ( ( rc = spi_wait ( device ) ) != 0 ) {
|
|
132
|
+ DBG ( "SPI %p failed to complete write operation\n", device );
|
118
|
133
|
return rc;
|
|
134
|
+ }
|
119
|
135
|
|
120
|
136
|
return 0;
|
121
|
137
|
}
|