Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //INCLUDES
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <util/delay.h>
- #include "GPP.h"
- //MAIN FUNCTION
- int main()
- {
- GPP *gpp = new GPP();
- //Turn on system power
- gpp->setPowerPin();
- gpp->screenOn();
- //Perform initialisation code
- gpp->SPI_Init();
- //Draw Logo on screen
- gpp->displayLogo();
- for( int i=0; i < 5*5 /*5 loops for each second, 5 seconds*/; i++ )
- {
- _delay_ms(200);
- }
- /* End Game Infinite Loop - Interrupts now run the show */
- while(1);
- }
- #ifndef GPOWERPACK_H
- #define GPOWERPACK_H
- //Defines...
- //Pins
- //#define RST_PIN 0b00000001
- #define BUSY_PIN 0b00000010
- #define DC_PIN 0b00001000
- #define CS_PIN 0b00010000
- //Includes...
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include "ePaperLibrary/epdpaint.h"
- #include "ePaperLibrary/fonts.h"
- #include "BasicsLibrary/LinkedList.h"
- #include "BasicsLibrary/dataBits.h"
- #include "Waveshare.h"
- class GPP
- {
- public:
- GPP();
- //~GPP();
- void setPowerPin();
- void screenOn();
- void SPI_Init();
- void SPI_SendNext();
- void displayLogo();
- private:
- Waveshare screen;
- };
- #endif
- //INCLUDES
- #include "GPP.h"
- //GLOBALS: INTERRUPTS AND VARIABLES
- extern LinkedList<dataBits> SPI_DATA_BUFFER;
- // SPI interrupt -> micro controller specific global function
- ISR( SPIC_INT_vect )
- {
- dataBits package = SPI_DATA_BUFFER.removeHead();
- unsigned char data = package.data;
- switch (package.context)
- {
- // SPI DC pin low --> Command
- case 0:
- PORTC.OUT &= ~DC_PIN;
- break;
- // SPI DC pin high --> Data
- case 1:
- PORTC.OUT |= DC_PIN;
- break;
- default:
- break;
- }
- }
- //PUBLIC FUNCTIONS
- GPP::GPP()
- {
- //Perform any setup here
- SPI_DATA_BUFFER = new LinkedList<dataBits>();
- Waveshare screen = new Waveshare( SPI_DATA_BUFFER, (unsigned char) RST_PIN, (unsigned char) DC_PIN, (unsigned char) CS_PIN, (unsigned char) BUSY_PIN );
- }
- // Activate PD0: Connected to the gate of the MosFET
- // that controls battery power delivered to the circuit
- void GPP::setPowerPin()
- {
- PORTD.DIR |= 0b00000001; //Pin0 output
- PORTD.OUT |= 0b00000001; //Pin0 High
- }
- ...... and so on
Add Comment
Please, Sign In to add comment