Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

diskio.c 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*-----------------------------------------------------------------------*/
  2. /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
  3. /*-----------------------------------------------------------------------*/
  4. /* This is a stub disk I/O module that acts as front end of the existing */
  5. /* disk I/O modules and attach it to FatFs module with common interface. */
  6. /*-----------------------------------------------------------------------*/
  7. #include "diskio.h"
  8. /*-----------------------------------------------------------------------*/
  9. /* Initialize a Drive */
  10. DSTATUS disk_initialize (
  11. BYTE drv /* Physical drive number (0..) */
  12. )
  13. {
  14. return FR_OK;
  15. }
  16. /*-----------------------------------------------------------------------*/
  17. /* Return Disk Status */
  18. DSTATUS disk_status (
  19. BYTE drv /* Physical drive number (0..) */
  20. )
  21. {
  22. return FR_OK;
  23. }
  24. /*-----------------------------------------------------------------------*/
  25. /* Read Sector(s) */
  26. DRESULT disk_read (
  27. BYTE drv, /* Physical drive number (0..) */
  28. BYTE *buff, /* Data buffer to store read data */
  29. DWORD sector, /* Sector address (LBA) */
  30. BYTE count /* Number of sectors to read (1..128) */
  31. )
  32. {
  33. DataflashManager_ReadBlocks_RAM(sector, count, buff);
  34. return RES_OK;
  35. }
  36. /*-----------------------------------------------------------------------*/
  37. /* Write Sector(s) */
  38. #if _READONLY == 0
  39. DRESULT disk_write (
  40. BYTE drv, /* Physical drive number (0..) */
  41. const BYTE *buff, /* Data to be written */
  42. DWORD sector, /* Sector address (LBA) */
  43. BYTE count /* Number of sectors to write (1..128) */
  44. )
  45. {
  46. DataflashManager_WriteBlocks_RAM(sector, count, buff);
  47. return RES_OK;
  48. }
  49. #endif /* _READONLY */
  50. /*-----------------------------------------------------------------------*/
  51. /* Miscellaneous Functions */
  52. DRESULT disk_ioctl (
  53. BYTE drv, /* Physical drive number (0..) */
  54. BYTE ctrl, /* Control code */
  55. void *buff /* Buffer to send/receive control data */
  56. )
  57. {
  58. if (ctrl == CTRL_SYNC)
  59. return RES_OK;
  60. else
  61. return RES_PARERR;
  62. }
  63. DWORD get_fattime (void)
  64. {
  65. TimeDate_t CurrTimeDate;
  66. RTC_GetTimeDate(&CurrTimeDate);
  67. return ((DWORD)(20 + CurrTimeDate.Year) << 25) |
  68. ((DWORD)CurrTimeDate.Month << 21) |
  69. ((DWORD)CurrTimeDate.Day << 16) |
  70. ((DWORD)CurrTimeDate.Hour << 11) |
  71. ((DWORD)CurrTimeDate.Minute << 5) |
  72. (((DWORD)CurrTimeDate.Second >> 1) << 0);
  73. }