iap.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. ******************************************************************************
  3. * @file : iap.h
  4. * @brief : Header for iap.c define .
  5. * This file contains the common defines of the application.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2025 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __IAP_H
  20. #define __IAP_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx_hal.h"
  26. #include "global_def.h"
  27. #include "stm32l4xx_hal_flash.h"
  28. #include "stm32l4xx_hal_flash_ex.h"
  29. ///<cmd
  30. #define ControlCmd (0x02)
  31. #define DataTransferCmd (0x40)
  32. #define DataTransferCmdHost (0x41)
  33. ///<smd
  34. ///<cmd=0x40
  35. #define DataTransferRequest (0x00)
  36. #define TransferData (0x01)
  37. #define TransferExit (0x02)
  38. ///<cmd=0x02
  39. #define RequestReset (0x00)
  40. /* cmd=0x40 smd=0x00 */
  41. /* Transfer type */
  42. #define IAP_BIN_FILE (1)
  43. #define MaxBlockSize (256) //²»Äܳ¬³ö½ÓÊÕbuffer size #define UART0_RECV_DATA_POOL_COUNT 320
  44. /* Result */
  45. #define ResultSuccess (0)
  46. #define ResultBusy (1)
  47. #define ResultExceedLimit (2)
  48. #define ResultTotalLengthErr (3)
  49. #define ResultSequenceErr (4)
  50. #define ResultCRCErr (5)
  51. #define ResultParamErr (6)
  52. #define ResultCmdErr (7)
  53. #define ResultExecErr (8)
  54. extern uint8_t iap_reboot;
  55. /* Exported functions prototypes ---------------------------------------------*/
  56. extern int IAP_Init(void);
  57. extern void IAP_Start(void);
  58. extern int IAP_Write(uint8_t *pdata, uint16_t length);
  59. extern int IAP_Stop(void);
  60. extern uint16_t IAP_CmdHandle(uint8_t* pdata, uint16_t length, uint8_t* pout);
  61. extern void Start_BootLoader(void);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* __IAP_H */