Commit bd86220f58b99d6896198c385fda132f0c980915

Authored by Peter Pearse
1 parent afd477b227

Move coloured led API to status_led.h

Improve indentation in drivers/at45.c

Showing 4 changed files with 114 additions and 134 deletions Side-by-side Diff

... ... @@ -27,7 +27,7 @@
27 27  
28 28 #include <config.h>
29 29 #include <version.h>
30   -#include <asm/coloured_led.h>
  30 +#include <status_led.h>
31 31  
32 32 /*
33 33 *************************************************************************
... ... @@ -48,28 +48,27 @@
48 48  
49 49 /* process the address to obtain page address and byte address */
50 50 adr = ((DataflashAddress / (pDataFlash->pDevice->pages_size)) <<
51   - pDataFlash->pDevice->page_offset) + (DataflashAddress %
52   - (pDataFlash->pDevice->
53   - pages_size));
  51 + pDataFlash->pDevice->page_offset) +
  52 + (DataflashAddress % (pDataFlash->pDevice->pages_size));
54 53  
55   - /* fill the command buffer */
  54 + /* fill the command buffer */
56 55 pDataFlash->pDataFlashDesc->command[0] = OpCode;
57 56 if (pDataFlash->pDevice->pages_number >= 16384) {
58 57 pDataFlash->pDataFlashDesc->command[1] =
59   - (unsigned char)((adr & 0x0F000000) >> 24);
  58 + (unsigned char)((adr & 0x0F000000) >> 24);
60 59 pDataFlash->pDataFlashDesc->command[2] =
61   - (unsigned char)((adr & 0x00FF0000) >> 16);
  60 + (unsigned char)((adr & 0x00FF0000) >> 16);
62 61 pDataFlash->pDataFlashDesc->command[3] =
63   - (unsigned char)((adr & 0x0000FF00) >> 8);
  62 + (unsigned char)((adr & 0x0000FF00) >> 8);
64 63 pDataFlash->pDataFlashDesc->command[4] =
65   - (unsigned char)(adr & 0x000000FF);
  64 + (unsigned char)(adr & 0x000000FF);
66 65 } else {
67 66 pDataFlash->pDataFlashDesc->command[1] =
68   - (unsigned char)((adr & 0x00FF0000) >> 16);
  67 + (unsigned char)((adr & 0x00FF0000) >> 16);
69 68 pDataFlash->pDataFlashDesc->command[2] =
70   - (unsigned char)((adr & 0x0000FF00) >> 8);
  69 + (unsigned char)((adr & 0x0000FF00) >> 8);
71 70 pDataFlash->pDataFlashDesc->command[3] =
72   - (unsigned char)(adr & 0x000000FF);
  71 + (unsigned char)(adr & 0x000000FF);
73 72 pDataFlash->pDataFlashDesc->command[4] = 0;
74 73 }
75 74 pDataFlash->pDataFlashDesc->command[5] = 0;
76 75  
... ... @@ -78,10 +77,10 @@
78 77  
79 78 /* Initialize the SpiData structure for the spi write fuction */
80 79 pDataFlash->pDataFlashDesc->tx_cmd_pt =
81   - pDataFlash->pDataFlashDesc->command;
  80 + pDataFlash->pDataFlashDesc->command;
82 81 pDataFlash->pDataFlashDesc->tx_cmd_size = CmdSize;
83 82 pDataFlash->pDataFlashDesc->rx_cmd_pt =
84   - pDataFlash->pDataFlashDesc->command;
  83 + pDataFlash->pDataFlashDesc->command;
85 84 pDataFlash->pDataFlashDesc->rx_cmd_size = CmdSize;
86 85  
87 86 /* send the command and read the data */
... ... @@ -123,8 +122,8 @@
123 122 /* \brief wait for dataflash ready (bit7 of the status register == 1) */
124 123 /*----------------------------------------------------------------------*/
125 124 AT91S_DataFlashStatus AT91F_DataFlashWaitReady(AT91PS_DataflashDesc
126   - pDataFlashDesc,
127   - unsigned int timeout)
  125 + pDataFlashDesc,
  126 + unsigned int timeout)
128 127 {
129 128 pDataFlashDesc->DataFlash_state = IDLE;
130 129  
131 130  
... ... @@ -149,16 +148,17 @@
149 148 /* : <sizeToRead> = data buffer size */
150 149 /* Return value : State of the dataflash */
151 150 /*--------------------------------------------------------------------------*/
152   -AT91S_DataFlashStatus AT91F_DataFlashContinuousRead(AT91PS_DataFlash pDataFlash,
153   - int src,
154   - unsigned char *dataBuffer,
155   - int sizeToRead)
  151 +AT91S_DataFlashStatus AT91F_DataFlashContinuousRead(
  152 + AT91PS_DataFlash pDataFlash,
  153 + int src,
  154 + unsigned char *dataBuffer,
  155 + int sizeToRead)
156 156 {
157 157 AT91S_DataFlashStatus status;
158 158 /* Test the size to read in the device */
159 159 if ((src + sizeToRead) >
160   - (pDataFlash->pDevice->pages_size *
161   - (pDataFlash->pDevice->pages_number)))
  160 + (pDataFlash->pDevice->pages_size *
  161 + (pDataFlash->pDevice->pages_number)))
162 162 return DATAFLASH_MEMORY_OVERFLOW;
163 163  
164 164 pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer;
... ... @@ -166,8 +166,8 @@
166 166 pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer;
167 167 pDataFlash->pDataFlashDesc->tx_data_size = sizeToRead;
168 168  
169   - status = AT91F_DataFlashSendCommand
170   - (pDataFlash, DB_CONTINUOUS_ARRAY_READ, 8, src);
  169 + status = AT91F_DataFlashSendCommand(
  170 + pDataFlash, DB_CONTINUOUS_ARRAY_READ, 8, src);
171 171 /* Send the command to the dataflash */
172 172 return (status);
173 173 }
... ... @@ -196,8 +196,8 @@
196 196 /* Send the command to the dataflash */
197 197 if (pDataFlash->pDevice->pages_number >= 16384)
198 198 cmdsize = 5;
199   - return (AT91F_DataFlashSendCommand(pDataFlash, DB_PAGE_PGM_BUF1,
200   - cmdsize, dest));
  199 + return (AT91F_DataFlashSendCommand(
  200 + pDataFlash, DB_PAGE_PGM_BUF1, cmdsize, dest));
201 201 }
202 202  
203 203 /*---------------------------------------------------------------------------*/
204 204  
... ... @@ -208,16 +208,17 @@
208 208 /* : */
209 209 /* Return value : State of the dataflash */
210 210 /*---------------------------------------------------------------------------*/
211   -AT91S_DataFlashStatus AT91F_MainMemoryToBufferTransfert(AT91PS_DataFlash
212   - pDataFlash,
213   - unsigned char
214   - BufferCommand,
215   - unsigned int page)
  211 +AT91S_DataFlashStatus AT91F_MainMemoryToBufferTransfert(
  212 + AT91PS_DataFlash
  213 + pDataFlash,
  214 + unsigned char
  215 + BufferCommand,
  216 + unsigned int page)
216 217 {
217 218 int cmdsize;
218 219 /* Test if the buffer command is legal */
219   - if ((BufferCommand != DB_PAGE_2_BUF1_TRF)
220   - && (BufferCommand != DB_PAGE_2_BUF2_TRF))
  220 + if ((BufferCommand != DB_PAGE_2_BUF1_TRF)&&
  221 + (BufferCommand != DB_PAGE_2_BUF2_TRF))
221 222 return DATAFLASH_BAD_COMMAND;
222 223  
223 224 /* no data to transmit or receive */
... ... @@ -225,9 +226,9 @@
225 226 cmdsize = 4;
226 227 if (pDataFlash->pDevice->pages_number >= 16384)
227 228 cmdsize = 5;
228   - return (AT91F_DataFlashSendCommand(pDataFlash, BufferCommand, cmdsize,
229   - page *
230   - pDataFlash->pDevice->pages_size));
  229 + return (AT91F_DataFlashSendCommand(
  230 + pDataFlash, BufferCommand, cmdsize,
  231 + page * pDataFlash->pDevice->pages_size));
231 232 }
232 233  
233 234 /*-------------------------------------------------------------------------- */
234 235  
... ... @@ -240,16 +241,17 @@
240 241 /* : <SizeToWrite> = data buffer size */
241 242 /* Return value : State of the dataflash */
242 243 /*---------------------------------------------------------------------------*/
243   -AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer(AT91PS_DataFlash pDataFlash,
244   - unsigned char BufferCommand,
245   - unsigned char *dataBuffer,
246   - unsigned int bufferAddress,
247   - int SizeToWrite)
  244 +AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer(
  245 + AT91PS_DataFlash pDataFlash,
  246 + unsigned char BufferCommand,
  247 + unsigned char *dataBuffer,
  248 + unsigned int bufferAddress,
  249 + int SizeToWrite)
248 250 {
249 251 int cmdsize;
250 252 /* Test if the buffer command is legal */
251   - if ((BufferCommand != DB_BUF1_WRITE)
252   - && (BufferCommand != DB_BUF2_WRITE))
  253 + if ((BufferCommand != DB_BUF1_WRITE) &&
  254 + (BufferCommand != DB_BUF2_WRITE))
253 255 return DATAFLASH_BAD_COMMAND;
254 256  
255 257 /* buffer address must be lower than page size */
256 258  
257 259  
258 260  
259 261  
260 262  
... ... @@ -265,28 +267,28 @@
265 267 if (pDataFlash->pDevice->pages_number >= 16384) {
266 268 pDataFlash->pDataFlashDesc->command[2] = 0;
267 269 pDataFlash->pDataFlashDesc->command[3] =
268   - (unsigned char)(((unsigned int)(bufferAddress &
269   - pDataFlash->pDevice->
270   - byte_mask)) >> 8);
  270 + (unsigned char)(((unsigned int)(bufferAddress &
  271 + pDataFlash->pDevice->
  272 + byte_mask)) >> 8);
271 273 pDataFlash->pDataFlashDesc->command[4] =
272   - (unsigned char)((unsigned int)bufferAddress & 0x00FF);
  274 + (unsigned char)((unsigned int)bufferAddress & 0x00FF);
273 275 cmdsize = 5;
274 276 } else {
275 277 pDataFlash->pDataFlashDesc->command[2] =
276   - (unsigned char)(((unsigned int)(bufferAddress &
277   - pDataFlash->pDevice->
278   - byte_mask)) >> 8);
  278 + (unsigned char)(((unsigned int)(bufferAddress &
  279 + pDataFlash->pDevice->
  280 + byte_mask)) >> 8);
279 281 pDataFlash->pDataFlashDesc->command[3] =
280   - (unsigned char)((unsigned int)bufferAddress & 0x00FF);
  282 + (unsigned char)((unsigned int)bufferAddress & 0x00FF);
281 283 pDataFlash->pDataFlashDesc->command[4] = 0;
282 284 cmdsize = 4;
283 285 }
284 286  
285 287 pDataFlash->pDataFlashDesc->tx_cmd_pt =
286   - pDataFlash->pDataFlashDesc->command;
  288 + pDataFlash->pDataFlashDesc->command;
287 289 pDataFlash->pDataFlashDesc->tx_cmd_size = cmdsize;
288 290 pDataFlash->pDataFlashDesc->rx_cmd_pt =
289   - pDataFlash->pDataFlashDesc->command;
  291 + pDataFlash->pDataFlashDesc->command;
290 292 pDataFlash->pDataFlashDesc->rx_cmd_size = cmdsize;
291 293  
292 294 pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer;
... ... @@ -305,8 +307,9 @@
305 307 /* : */
306 308 /* Return value : State of the dataflash */
307 309 /*---------------------------------------------------------------------------*/
308   -AT91S_DataFlashStatus AT91F_PageErase(AT91PS_DataFlash pDataFlash,
309   - unsigned int page)
  310 +AT91S_DataFlashStatus AT91F_PageErase(
  311 + AT91PS_DataFlash pDataFlash,
  312 + unsigned int page)
310 313 {
311 314 int cmdsize;
312 315 /* Test if the buffer command is legal */
... ... @@ -316,9 +319,9 @@
316 319 cmdsize = 4;
317 320 if (pDataFlash->pDevice->pages_number >= 16384)
318 321 cmdsize = 5;
319   - return (AT91F_DataFlashSendCommand(pDataFlash, DB_PAGE_ERASE, cmdsize,
320   - page *
321   - pDataFlash->pDevice->pages_size));
  322 + return (AT91F_DataFlashSendCommand(pDataFlash,
  323 + DB_PAGE_ERASE, cmdsize,
  324 + page * pDataFlash->pDevice->pages_size));
322 325 }
323 326  
324 327 /*---------------------------------------------------------------------------*/
... ... @@ -329,8 +332,9 @@
329 332 /* : */
330 333 /* Return value : State of the dataflash */
331 334 /*---------------------------------------------------------------------------*/
332   -AT91S_DataFlashStatus AT91F_BlockErase(AT91PS_DataFlash pDataFlash,
333   - unsigned int block)
  335 +AT91S_DataFlashStatus AT91F_BlockErase(
  336 + AT91PS_DataFlash pDataFlash,
  337 + unsigned int block)
334 338 {
335 339 int cmdsize;
336 340 /* Test if the buffer command is legal */
... ... @@ -340,8 +344,8 @@
340 344 if (pDataFlash->pDevice->pages_number >= 16384)
341 345 cmdsize = 5;
342 346 return (AT91F_DataFlashSendCommand(pDataFlash, DB_BLOCK_ERASE, cmdsize,
343   - block * 8 *
344   - pDataFlash->pDevice->pages_size));
  347 + block * 8 *
  348 + pDataFlash->pDevice->pages_size));
345 349 }
346 350  
347 351 /*---------------------------------------------------------------------------*/
348 352  
... ... @@ -353,15 +357,15 @@
353 357 /* Return value : State of the dataflash */
354 358 /*---------------------------------------------------------------------------*/
355 359 AT91S_DataFlashStatus AT91F_WriteBufferToMain(AT91PS_DataFlash pDataFlash,
356   - unsigned char BufferCommand,
357   - unsigned int dest)
  360 + unsigned char BufferCommand,
  361 + unsigned int dest)
358 362 {
359 363 int cmdsize;
360 364 /* Test if the buffer command is correct */
361 365 if ((BufferCommand != DB_BUF1_PAGE_PGM) &&
362   - (BufferCommand != DB_BUF1_PAGE_ERASE_PGM) &&
363   - (BufferCommand != DB_BUF2_PAGE_PGM) &&
364   - (BufferCommand != DB_BUF2_PAGE_ERASE_PGM))
  366 + (BufferCommand != DB_BUF1_PAGE_ERASE_PGM) &&
  367 + (BufferCommand != DB_BUF2_PAGE_PGM) &&
  368 + (BufferCommand != DB_BUF2_PAGE_ERASE_PGM))
365 369 return DATAFLASH_BAD_COMMAND;
366 370  
367 371 /* no data to transmit or receive */
... ... @@ -371,8 +375,8 @@
371 375 if (pDataFlash->pDevice->pages_number >= 16384)
372 376 cmdsize = 5;
373 377 /* Send the command to the dataflash */
374   - return (AT91F_DataFlashSendCommand(pDataFlash, BufferCommand, cmdsize,
375   - dest));
  378 + return (AT91F_DataFlashSendCommand(pDataFlash, BufferCommand,
  379 + cmdsize, dest));
376 380 }
377 381  
378 382 /*---------------------------------------------------------------------------*/
... ... @@ -383,9 +387,9 @@
383 387 /* : <length> = Number of bytes to erase */
384 388 /*---------------------------------------------------------------------------*/
385 389 AT91S_DataFlashStatus AT91F_PartialPageWrite(AT91PS_DataFlash pDataFlash,
386   - unsigned char *src,
387   - unsigned int dest,
388   - unsigned int size)
  390 + unsigned char *src,
  391 + unsigned int dest,
  392 + unsigned int size)
389 393 {
390 394 unsigned int page;
391 395 unsigned int AdrInPage;
392 396  
... ... @@ -399,10 +403,10 @@
399 403 AT91C_TIMEOUT_WRDY);
400 404 /*Update the SRAM buffer */
401 405 AT91F_DataFlashWriteBuffer(pDataFlash, DB_BUF1_WRITE, src,
402   - AdrInPage, size);
  406 + AdrInPage, size);
403 407  
404 408 AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc,
405   - AT91C_TIMEOUT_WRDY);
  409 + AT91C_TIMEOUT_WRDY);
406 410  
407 411 /* Erase page if a 128 Mbits device */
408 412 if (pDataFlash->pDevice->pages_number >= 16384) {
... ... @@ -426,8 +430,8 @@
426 430 /* : <size> = data buffer size */
427 431 /*---------------------------------------------------------------------------*/
428 432 AT91S_DataFlashStatus AT91F_DataFlashWrite(AT91PS_DataFlash pDataFlash,
429   - unsigned char *src,
430   - int dest, int size)
  433 + unsigned char *src,
  434 + int dest, int size)
431 435 {
432 436 unsigned int length;
433 437 unsigned int page;
434 438  
... ... @@ -436,14 +440,14 @@
436 440 AT91F_SpiEnable(pDataFlash->pDevice->cs);
437 441  
438 442 if ((dest + size) > (pDataFlash->pDevice->pages_size *
439   - (pDataFlash->pDevice->pages_number)))
  443 + (pDataFlash->pDevice->pages_number)))
440 444 return DATAFLASH_MEMORY_OVERFLOW;
441 445  
442 446 /* If destination does not fit a page start address */
443 447 if ((dest % ((unsigned int)(pDataFlash->pDevice->pages_size))) != 0) {
444   - length = pDataFlash->pDevice->pages_size -
445   - (dest % ((unsigned int)
446   - (pDataFlash->pDevice->pages_size)));
  448 + length =
  449 + pDataFlash->pDevice->pages_size -
  450 + (dest % ((unsigned int)(pDataFlash->pDevice->pages_size)));
447 451  
448 452 if (size < length)
449 453 length = size;
... ... @@ -465,9 +469,9 @@
465 469 page = (unsigned int)dest / (pDataFlash->pDevice->pages_size);
466 470  
467 471 status = AT91F_DataFlashWriteBuffer(pDataFlash,
468   - DB_BUF1_WRITE, src, 0,
469   - pDataFlash->pDevice->
470   - pages_size);
  472 + DB_BUF1_WRITE, src, 0,
  473 + pDataFlash->pDevice->
  474 + pages_size);
471 475 AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc,
472 476 AT91C_TIMEOUT_WRDY);
473 477  
... ... @@ -478,7 +482,7 @@
478 482 return DATAFLASH_ERROR;
479 483  
480 484 status = AT91F_WriteBufferToMain(pDataFlash,
481   - DB_BUF1_PAGE_PGM, dest);
  485 + DB_BUF1_PAGE_PGM, dest);
482 486 if (!status)
483 487 return DATAFLASH_ERROR;
484 488  
485 489  
486 490  
... ... @@ -517,20 +521,20 @@
517 521 AT91F_SpiEnable(pDataFlash->pDevice->cs);
518 522  
519 523 if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc,
520   - AT91C_TIMEOUT_WRDY) != DATAFLASH_OK)
  524 + AT91C_TIMEOUT_WRDY) != DATAFLASH_OK)
521 525 return -1;
522 526  
523 527 while (size) {
524 528 SizeToRead = (size < 0x8000) ? size : 0x8000;
525 529  
526 530 if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc,
527   - AT91C_TIMEOUT_WRDY) !=
528   - DATAFLASH_OK)
  531 + AT91C_TIMEOUT_WRDY) !=
  532 + DATAFLASH_OK)
529 533 return -1;
530 534  
531 535 if (AT91F_DataFlashContinuousRead(pDataFlash, addr,
532   - (uchar *) buffer,
533   - SizeToRead) != DATAFLASH_OK)
  536 + (uchar *) buffer,
  537 + SizeToRead) != DATAFLASH_OK)
534 538 return -1;
535 539  
536 540 size -= SizeToRead;
include/asm-arm/coloured_led.h
1   -/*
2   - * (C) Copyright 2006
3   - * Atmel Nordic AB <www.atmel.com>
4   - * Ulf Samuelsson <ulf@atmel.com>
5   - *
6   - * See file CREDITS for list of people who contributed to this
7   - * project.
8   - *
9   - * This program is free software; you can redistribute it and/or
10   - * modify it under the terms of the GNU General Public License as
11   - * published by the Free Software Foundation; either version 2 of
12   - * the License, or (at your option) any later version.
13   - *
14   - * This program is distributed in the hope that it will be useful,
15   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17   - * GNU General Public License for more details.
18   - *
19   - * You should have received a copy of the GNU General Public License
20   - * along with this program; if not, write to the Free Software
21   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22   - * MA 02111-1307 USA
23   - */
24   -
25   -#ifndef __LED_H
26   -#define __LED_H
27   -
28   -#ifndef __ASSEMBLY__
29   -extern void coloured_LED_init (void);
30   -extern void red_LED_on(void);
31   -extern void red_LED_off(void);
32   -extern void green_LED_on(void);
33   -extern void green_LED_off(void);
34   -extern void yellow_LED_on(void);
35   -extern void yellow_LED_off(void);
36   -#else
37   - .extern LED_init
38   - .extern red_LED_on
39   - .extern red_LED_off
40   - .extern yellow_LED_on
41   - .extern yellow_LED_off
42   - .extern green_LED_on
43   - .extern green_LED_off
44   -#endif
45   -#endif
include/status_led.h
... ... @@ -383,6 +383,27 @@
383 383 # include <asm/status_led.h>
384 384 #endif
385 385  
  386 +/*
  387 + * Coloured LEDs API
  388 + */
  389 +#ifndef __ASSEMBLY__
  390 +extern void coloured_LED_init (void);
  391 +extern void red_LED_on(void);
  392 +extern void red_LED_off(void);
  393 +extern void green_LED_on(void);
  394 +extern void green_LED_off(void);
  395 +extern void yellow_LED_on(void);
  396 +extern void yellow_LED_off(void);
  397 +#else
  398 + .extern LED_init
  399 + .extern red_LED_on
  400 + .extern red_LED_off
  401 + .extern yellow_LED_on
  402 + .extern yellow_LED_off
  403 + .extern green_LED_on
  404 + .extern green_LED_off
  405 +#endif
  406 +
386 407 #endif /* CONFIG_STATUS_LED */
387 408  
388 409 #endif /* _STATUS_LED_H_ */