mtd_nand.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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, rt_off_t pos, void *buffer, rt_size_t size)
  35. {
  36. return size;
  37. }
  38. static rt_size_t _mtd_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
  39. {
  40. return size;
  41. }
  42. static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
  43. {
  44. return RT_EOK;
  45. }
  46. rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device* device)
  47. {
  48. rt_device_t dev;
  49. dev = RT_DEVICE(device);
  50. RT_ASSERT(dev != RT_NULL);
  51. /* set device class and generic device interface */
  52. dev->type = RT_Device_Class_MTD;
  53. dev->init = _mtd_init;
  54. dev->open = _mtd_open;
  55. dev->read = _mtd_read;
  56. dev->write = _mtd_write;
  57. dev->close = _mtd_close;
  58. dev->control = _mtd_control;
  59. dev->rx_indicate = RT_NULL;
  60. dev->tx_complete = RT_NULL;
  61. /* register to RT-Thread device system */
  62. return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
  63. }
  64. #endif