updated math functions

This commit is contained in:
hugogogo
2025-03-15 18:15:30 +01:00
parent 16a5bcd313
commit ec928d14b1
12 changed files with 200 additions and 66 deletions

18
headers/i2c.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef I2C_H
#define I2C_H
// table 22-7 : prescale sets
#define TWI_PRESCALE_SET(value) \
((value) == 1 ? (0<<TWPS1 | 0<<TWPS0) : \
(value) == 4 ? (0<<TWPS1 | 1<<TWPS0) : \
(value) == 16 ? (1<<TWPS1 | 0<<TWPS0) : \
(value) == 64 ? (1<<TWPS1 | 1<<TWPS0) : 0x00)
// 22.7.1 : TWCR, Master Transmitter Mode
#define SEND_START_CONDITION ((1<<TWINT) | (1<<TWEN)) | (1<<TWSTA)
#define SEND_CONTINUE_TRANSMISSION ((1<<TWINT) | (1<<TWEN))
#define SEND_STOP_CONDITION ((1<<TWINT) | (1<<TWEN)) | (1<<TWSTO)
#define SEND_ACKNOWLEDGE ((1<<TWINT) | (1<<TWEN) | (1<<TWEA))
#define SEND_NACKNOWLEDGE ((1<<TWINT) | (1<<TWEN))
#endif // I2C_H