mtd_nand.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-12-05 Bernard the first version
  13. */
  14. /*
  15. * COPYRIGHT (C) 2012, Shanghai Real Thread
  16. */
  17. #include <drivers/mtd_nand.h>
  18. #ifdef RT_USING_MTD_NAND
  19. /**
  20. * RT-Thread Generic Device Interface
  21. */
  22. static rt_err_t _mtd_init(rt_device_t dev)
  23. {
  24. return RT_EOK;
  25. }
  26. static rt_err_t _mtd_open(rt_device_t dev, rt_uint16_t oflag)
  27. {
  28. return RT_EOK;
  29. }
  30. static rt_err_t _mtd_close(rt_device_t dev)
  31. {
  32. return RT_EOK;
  33. }
  34. static rt_size_t _mtd_read(rt_device_t dev,
  35. rt_off_t pos,
  36. void *buffer,
  37. rt_size_t size)
  38. {
  39. return size;
  40. }
  41. static rt_size_t _mtd_write(rt_device_t dev,
  42. rt_off_t pos,
  43. const void *buffer,
  44. rt_size_t size)
  45. {
  46. return size;
  47. }
  48. static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
  49. {
  50. return RT_EOK;
  51. }
  52. rt_err_t rt_mtd_nand_register_device(const char *name,
  53. struct rt_mtd_nand_device *device)
  54. {
  55. rt_device_t dev;
  56. dev = RT_DEVICE(device);
  57. RT_ASSERT(dev != RT_NULL);
  58. /* set device class and generic device interface */
  59. dev->type = RT_Device_Class_MTD;
  60. dev->init = _mtd_init;
  61. dev->open = _mtd_open;
  62. dev->read = _mtd_read;
  63. dev->write = _mtd_write;
  64. dev->close = _mtd_close;
  65. dev->control = _mtd_control;
  66. dev->rx_indicate = RT_NULL;
  67. dev->tx_complete = RT_NULL;
  68. /* register to RT-Thread device system */
  69. return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
  70. }
  71. #endif