Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WSH() PORTB |= (1 << PB2)
- #define WSL() PORTB &= ~(1 << PB2)
- #define BCKH() PORTB |= (1 << PB1)
- #define BCKL() PORTB &= ~(1 << PB1)
- #define DATH() PORTB |= (1 << PB0)
- #define DATL() PORTB &= ~(1 << PB0)
- inline void i2s_send_bit(uint16_t n, uint8_t pos)
- {
- if ( n & (1 << pos) ) DATH(); else DATL();
- NOP(); NOP();
- BCKH();
- NOP(); NOP();
- BCKL();
- }
- void i2s_send(const uint16_t data) {
- WSL();
- _delay_us(2);
- uint8_t i = 15;
- for(; i; i--) {
- i2s_send_bit(data, i);
- }
- WSH();
- i2s_send_bit (data, 0);
- for(i = 15; i; i--) {
- i2s_send_bit(data, i);
- }
- WSL();
- i2s_send_bit (data, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement