12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "ch.h"
- #include "hal.h"
- static THD_WORKING_AREA(waThread1, 32);
- static THD_FUNCTION(Thread1, arg) {
- (void)arg;
- chRegSetThreadName("Blinker");
- while (true) {
- palTogglePad(IOPORT2, PORTB_LED1);
- chThdSleepMilliseconds(1000);
- }
- }
- int main(void) {
- uint8_t tx[3];
- uint8_t rx[2];
-
- halInit();
- chSysInit();
- palClearPad(IOPORT2, PORTB_LED1);
- i2cStart(&I2CD1, NULL);
-
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
- while (TRUE) {
-
- tx[0] = 0x00;
- tx[1] = 0x00;
- tx[2] = 0xAA;
- i2cMasterTransmit(&I2CD1, 0x50, tx, 3, NULL, 0);
-
- i2cMasterTransmit(&I2CD1, 0x50, tx, 2, rx, 1);
- chThdSleepMilliseconds(1000);
- }
- }
|