fake.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * Not responding slave test
  15. */
  16. #include "ch.h"
  17. #include "hal.h"
  18. #define addr 0b1001100
  19. static uint8_t rx_data[2];
  20. static i2cflags_t errors = 0;
  21. /* This is main function. */
  22. void request_fake(void){
  23. msg_t status = MSG_OK;
  24. sysinterval_t tmo = TIME_MS2I(4);
  25. i2cAcquireBus(&I2CD1);
  26. status = i2cMasterReceiveTimeout(&I2CD1, addr, rx_data, 2, tmo);
  27. i2cReleaseBus(&I2CD1);
  28. if (status == MSG_RESET){
  29. errors = i2cGetErrors(&I2CD1);
  30. osalDbgCheck(I2C_ACK_FAILURE == errors);
  31. }
  32. }