Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static uint8_t inbufdata[32];
- static uint8_t outbufdata[32];
- void ss_init(){
- // Output
- TCCR0A |= (1 << WGM01); // Clear timer0 on compare. This is core to both send and receive.
- OCR0A = ss_clks; // 138 achieves 115200 bps. 238 theoretically gives very nearly 7 overflows for 9600 baud at 16Mhz. 201 with tweak of -8 gives reasonable 9600bps.
- TCCR0B |= (0<<CS02) | (0<<CS01) | (1<<CS00); // 0 0 1 = no clock prescale
- //TIMSK0 |= (1 << OCIE0A); // Set the ISR COMPA vect active. No longer done here as we don't want to waste time firing interrupts unless we're busy.
- DDRC |= (1<<PC0); // Make the pin an output
- PORTC |= (1<<PC0); // Idle high for serial data.
- // Input
- DDRC &= ~(1<<PC1); // Make the pin an input.
- //PORTC |= (1<<PC1); // Pullup
- PCMSK1 |= (1<<PCINT9); // Enable PC1 pin change interrupt. PC1 is PCINT9, which is in PCMSK group 1.
- PCICR |= (1<<PCIE1); // Enable scan for changes on PCMSK1-relevant pins
- // Test pin
- DDRC |= (1<<PC2); // Make the pin an output.
- PORTC |= (1<<PC2); // Idle low
- // Configure buffers
- // Put some predictable numbers in them so we can tell if we're even reading it right
- for(uint8_t i = 0; i < 32; i++){
- outbufdata[i] = i;
- inbufdata[i] = i;
- }
- // Set up length and buffer area in buffer structs
- ss_outbuf.len = SS_OUTPUT_BUFFER_LEN;
- ss_outbuf.data = outbufdata; //(uint8_t *) malloc(ss_outbuf.len);
- ss_inbuf.len = SS_INPUT_BUFFER_LEN;
- ss_inbuf.data = inbufdata; //(uint8_t *) malloc(ss_inbuf.len);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement