MCPcopy Create free account
hub / github.com/kiibohd/controller / sampleColumn

Function sampleColumn

Scan/Deprecated/DPH/scan_loop.c:696–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694
695
696void sampleColumn( uint8_t column )
697{
698 // ensure all probe lines are driven low, and chill for recovery delay.
699 ADCSRA |= (1 << ADEN) | (1 << ADSC); // enable and start conversions
700
701 PORTC &= ~C_MASK;
702 PORTD &= ~D_MASK;
703 PORTE &= ~E_MASK;
704
705 PORTF = 0;
706 DDRF = 0;
707
708 recovery( OFF );
709 strobe_w( column );
710
711 hold_sample( OFF );
712 SET_FULL_MUX( 0 );
713
714 // Allow strobes to settle
715 for ( uint8_t i = 0; i < STROBE_SETTLE; ++i ) { getADC(); }
716
717 hold_sample( ON );
718
719 uint8_t mux = 0;
720 SET_FULL_MUX( mux );
721 getADC(); // throw away; unknown mux.
722 do {
723 SET_FULL_MUX( mux + 1 ); // our *next* sample will use this
724
725 // retrieve current read.
726 uint16_t readVal = getADC();
727 samples[column][mux] = readVal;
728
729 // Update max sense sample table
730 if ( readVal > sampleMax[column][mux] )
731 {
732 sampleMax[column][mux] = readVal;
733 }
734
735 mux++;
736
737 } while ( mux < 8 );
738
739 hold_sample( OFF );
740 recovery( ON );
741
742 // turn off adc.
743 ADCSRA &= ~(1 << ADEN);
744
745 // pull all columns' strobe-lines low.
746 DDRC |= C_MASK;
747 DDRD |= D_MASK;
748 DDRE |= E_MASK;
749
750 PORTC &= ~C_MASK;
751 PORTD &= ~D_MASK;
752 PORTE &= ~E_MASK;
753}

Callers 2

Scan_setupFunction · 0.85
capsense_scanFunction · 0.85

Calls 4

recoveryFunction · 0.85
strobe_wFunction · 0.85
hold_sampleFunction · 0.85
getADCFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…