Naze32 clone with Frysky receiver
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

semihost_api.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_SEMIHOST_H
  17. #define MBED_SEMIHOST_H
  18. #include "device.h"
  19. #include "toolchain.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #if DEVICE_SEMIHOST
  24. #ifndef __CC_ARM
  25. #if defined(__ICCARM__)
  26. inline int __semihost(int reason, const void *arg) {
  27. return __semihosting(reason, (void*)arg);
  28. }
  29. #else
  30. #ifdef __thumb__
  31. # define AngelSWI 0xAB
  32. # define AngelSWIInsn "bkpt"
  33. # define AngelSWIAsm bkpt
  34. #else
  35. # define AngelSWI 0x123456
  36. # define AngelSWIInsn "swi"
  37. # define AngelSWIAsm swi
  38. #endif
  39. static inline int __semihost(int reason, const void *arg) {
  40. int value;
  41. asm volatile (
  42. "mov r0, %1" "\n\t"
  43. "mov r1, %2" "\n\t"
  44. AngelSWIInsn " %a3" "\n\t"
  45. "mov %0, r0"
  46. : "=r" (value) /* output operands */
  47. : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */
  48. : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
  49. );
  50. return value;
  51. }
  52. #endif
  53. #endif
  54. #if DEVICE_LOCALFILESYSTEM
  55. FILEHANDLE semihost_open(const char* name, int openmode);
  56. int semihost_close (FILEHANDLE fh);
  57. int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
  58. int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
  59. int semihost_ensure(FILEHANDLE fh);
  60. long semihost_flen (FILEHANDLE fh);
  61. int semihost_seek (FILEHANDLE fh, long position);
  62. int semihost_istty (FILEHANDLE fh);
  63. int semihost_remove(const char *name);
  64. int semihost_rename(const char *old_name, const char *new_name);
  65. #endif
  66. int semihost_uid(char *uid);
  67. int semihost_reset(void);
  68. int semihost_vbus(void);
  69. int semihost_powerdown(void);
  70. int semihost_exit(void);
  71. int semihost_connected(void);
  72. int semihost_disabledebug(void);
  73. #endif
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif