Browse Source

Added debug statements

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
6b45947a59
1 changed files with 20 additions and 4 deletions
  1. 20
    4
      src/drivers/nvs/spi.c

+ 20
- 4
src/drivers/nvs/spi.c View File

85
 	struct spi_bus *bus = device->bus;
85
 	struct spi_bus *bus = device->bus;
86
 	unsigned int command = spi_command ( SPI_READ, address,
86
 	unsigned int command = spi_command ( SPI_READ, address,
87
 					     device->munge_address );
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
 					     device->munge_address );
114
 					     device->munge_address );
107
 	int rc;
115
 	int rc;
108
 
116
 
117
+	DBG ( "SPI %p writing %d bytes to %#04x\n", device, len, address );
118
+
109
 	if ( ( rc = bus->rw ( bus, device, SPI_WREN, -1,
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
 		return rc;
122
 		return rc;
123
+	}
112
 
124
 
113
 	if ( ( rc = bus->rw ( bus, device, command, address,
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
 		return rc;
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
 		return rc;
133
 		return rc;
134
+	}
119
 
135
 
120
 	return 0;
136
 	return 0;
121
 }
137
 }

Loading…
Cancel
Save