main.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017-5-30 bernard the first version
  9. */
  10. #include <rtthread.h>
  11. #include <rtdevice.h>
  12. #include <board.h>
  13. #include "mbox.h"
  14. void set_led(int state) //set state LED nyala atau mati
  15. {
  16. if (state==1) //LED nyala
  17. {
  18. mbox[0] = 8*4; // length of the message
  19. mbox[1] = MBOX_REQUEST; // this is a request message
  20. mbox[2] = 0x00038041; // get serial number command
  21. mbox[3] = 8; // buffer size
  22. mbox[4] = 0;
  23. mbox[5] = 130; // clear output buffer
  24. mbox[6] = 1;
  25. mbox[7] = MBOX_TAG_LAST;
  26. mbox_call(8, MMU_DISABLE);
  27. }
  28. else if (state==0) //LED mati
  29. {
  30. mbox[0] = 8*4; // length of the message
  31. mbox[1] = MBOX_REQUEST; // this is a request message
  32. mbox[2] = 0x00038041; // get serial number command
  33. mbox[3] = 8; // buffer size
  34. mbox[4] = 0;
  35. mbox[5] = 130; // clear output buffer
  36. mbox[6] = 0;
  37. mbox[7] = MBOX_TAG_LAST;
  38. mbox_call(8, MMU_DISABLE);
  39. }
  40. }
  41. int main(int argc, char** argv)
  42. {
  43. int count = 1;
  44. rt_kprintf("Hi, this is RT-Thread!!\n");
  45. while (count++)
  46. {
  47. set_led(1);
  48. rt_thread_mdelay(500);
  49. set_led(0);
  50. rt_thread_mdelay(500);
  51. }
  52. return RT_EOK;
  53. }