spi.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * ESPRSSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef SPI_APP_H
  25. #define SPI_APP_H
  26. #include "spi_register.h"
  27. #include "ets_sys.h"
  28. #include "osapi.h"
  29. #include "uart.h"
  30. #include "os_type.h"
  31. #include "spi_flash.h"
  32. #define SPI_FLASH_BYTES_LEN 24
  33. #define IODATA_START_ADDR BIT0
  34. #define SPI_BUFF_BYTE_NUM 32
  35. /*SPI number define*/
  36. #define SPI 0
  37. #define HSPI 1
  38. void cache_flush(void);
  39. //spi master init funtion
  40. void spi_master_init(uint8 spi_no);
  41. //lcd drive function
  42. void spi_lcd_9bit_write(uint8 spi_no,uint8 high_bit,uint8 low_8bit);
  43. //use spi send 8bit data
  44. void spi_mast_byte_write(uint8 spi_no,uint8 data);
  45. //transmit data to esp8266 slave buffer,which needs 16bit transmission ,
  46. //first byte is master command 0x04, second byte is master data
  47. void spi_byte_write_espslave(uint8 spi_no,uint8 data);
  48. //read data from esp8266 slave buffer,which needs 16bit transmission ,
  49. //first byte is master command 0x06, second byte is to read slave data
  50. void spi_byte_read_espslave(uint8 spi_no,uint8 *data);
  51. //esp8266 slave mode initial
  52. void spi_slave_init(uint8 spi_no,uint8 data_len);
  53. //esp8266 slave isr handle funtion,tiggered when any transmission is finished.
  54. //the function is registered in spi_slave_init.
  55. void spi_slave_isr_handler(void *para);
  56. //hspi test function, used to test esp8266 spi slave
  57. void hspi_master_readwrite_repeat(void);
  58. void spi_test_init(void);
  59. #endif