mtd_nand.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * File : mtd_core.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-12-05 Bernard the first version
  23. */
  24. /*
  25. * COPYRIGHT (C) 2012, Shanghai Real Thread
  26. */
  27. #include <drivers/mtd_nand.h>
  28. #ifdef RT_USING_MTD_NAND
  29. /**
  30. * RT-Thread Generic Device Interface
  31. */
  32. static rt_err_t _mtd_init(rt_device_t dev)
  33. {
  34. return RT_EOK;
  35. }
  36. static rt_err_t _mtd_open(rt_device_t dev, rt_uint16_t oflag)
  37. {
  38. return RT_EOK;
  39. }
  40. static rt_err_t _mtd_close(rt_device_t dev)
  41. {
  42. return RT_EOK;
  43. }
  44. static rt_size_t _mtd_read(rt_device_t dev,
  45. rt_off_t pos,
  46. void *buffer,
  47. rt_size_t size)
  48. {
  49. return size;
  50. }
  51. static rt_size_t _mtd_write(rt_device_t dev,
  52. rt_off_t pos,
  53. const void *buffer,
  54. rt_size_t size)
  55. {
  56. return size;
  57. }
  58. static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
  59. {
  60. return RT_EOK;
  61. }
  62. rt_err_t rt_mtd_nand_register_device(const char *name,
  63. struct rt_mtd_nand_device *device)
  64. {
  65. rt_device_t dev;
  66. dev = RT_DEVICE(device);
  67. RT_ASSERT(dev != RT_NULL);
  68. /* set device class and generic device interface */
  69. dev->type = RT_Device_Class_MTD;
  70. dev->init = _mtd_init;
  71. dev->open = _mtd_open;
  72. dev->read = _mtd_read;
  73. dev->write = _mtd_write;
  74. dev->close = _mtd_close;
  75. dev->control = _mtd_control;
  76. dev->rx_indicate = RT_NULL;
  77. dev->tx_complete = RT_NULL;
  78. /* register to RT-Thread device system */
  79. return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
  80. }
  81. #endif