1
0

mtd_nor.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. * 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. * 2012-5-30 Bernard the first version
  23. */
  24. #include <drivers/mtd_nor.h>
  25. #ifdef RT_USING_MTD_NOR
  26. /**
  27. * RT-Thread Generic Device Interface
  28. */
  29. static rt_err_t _mtd_init(rt_device_t dev)
  30. {
  31. return RT_EOK;
  32. }
  33. static rt_err_t _mtd_open(rt_device_t dev, rt_uint16_t oflag)
  34. {
  35. return RT_EOK;
  36. }
  37. static rt_err_t _mtd_close(rt_device_t dev)
  38. {
  39. return RT_EOK;
  40. }
  41. static rt_size_t _mtd_read(rt_device_t dev,
  42. rt_off_t pos,
  43. void *buffer,
  44. rt_size_t size)
  45. {
  46. return size;
  47. }
  48. static rt_size_t _mtd_write(rt_device_t dev,
  49. rt_off_t pos,
  50. const void *buffer,
  51. rt_size_t size)
  52. {
  53. return size;
  54. }
  55. static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
  56. {
  57. return RT_EOK;
  58. }
  59. rt_err_t rt_mtd_nor_register_device(const char *name,
  60. struct rt_mtd_nor_device *device)
  61. {
  62. rt_device_t dev;
  63. dev = RT_DEVICE(device);
  64. RT_ASSERT(dev != RT_NULL);
  65. /* set device class and generic device interface */
  66. dev->type = RT_Device_Class_MTD;
  67. dev->init = _mtd_init;
  68. dev->open = _mtd_open;
  69. dev->read = _mtd_read;
  70. dev->write = _mtd_write;
  71. dev->close = _mtd_close;
  72. dev->control = _mtd_control;
  73. dev->rx_indicate = RT_NULL;
  74. dev->tx_complete = RT_NULL;
  75. /* register to RT-Thread device system */
  76. return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
  77. }
  78. #endif