mtd_nor.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * File : mtd_nor.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, Shanghai Real-Thread Technology Co., Ltd
  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. * 2012-5-30 Bernard the first version
  13. */
  14. #include <drivers/mtd_nor.h>
  15. #ifdef RT_USING_MTD_NOR
  16. /**
  17. * RT-Thread Generic Device Interface
  18. */
  19. static rt_err_t _mtd_init(rt_device_t dev)
  20. {
  21. return RT_EOK;
  22. }
  23. static rt_err_t _mtd_open(rt_device_t dev, rt_uint16_t oflag)
  24. {
  25. return RT_EOK;
  26. }
  27. static rt_err_t _mtd_close(rt_device_t dev)
  28. {
  29. return RT_EOK;
  30. }
  31. static rt_size_t _mtd_read(rt_device_t dev,
  32. rt_off_t pos,
  33. void *buffer,
  34. rt_size_t size)
  35. {
  36. return size;
  37. }
  38. static rt_size_t _mtd_write(rt_device_t dev,
  39. rt_off_t pos,
  40. const void *buffer,
  41. rt_size_t size)
  42. {
  43. return size;
  44. }
  45. static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
  46. {
  47. return RT_EOK;
  48. }
  49. rt_err_t rt_mtd_nor_register_device(const char *name,
  50. struct rt_mtd_nor_device *device)
  51. {
  52. rt_device_t dev;
  53. dev = RT_DEVICE(device);
  54. RT_ASSERT(dev != RT_NULL);
  55. /* set device class and generic device interface */
  56. dev->type = RT_Device_Class_MTD;
  57. dev->init = _mtd_init;
  58. dev->open = _mtd_open;
  59. dev->read = _mtd_read;
  60. dev->write = _mtd_write;
  61. dev->close = _mtd_close;
  62. dev->control = _mtd_control;
  63. dev->rx_indicate = RT_NULL;
  64. dev->tx_complete = RT_NULL;
  65. /* register to RT-Thread device system */
  66. return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
  67. }
  68. #endif