mtd_nor.c 1.7 KB

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