Subversion Repositories Projects

Rev

Rev 2225 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/****************************************************************************
 *   Copyright (C) 2009-2017 by Claas Anders "CaScAdE" Rathje               *
 *   admiralcascade@gmail.com                                               *
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
 *                                                                          *
 *   This program is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 2 of the License.         *
 *                                                                          *
 *   This program is distributed in the hope that it will be useful,        *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *   GNU General Public License for more details.                           *
 *                                                                          *
 *   You should have received a copy of the GNU General Public License      *
 *   along with this program; if not, write to the                          *
 *   Free Software Foundation, Inc.,                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
 ****************************************************************************/


#ifndef _MAX7456_SOFTWARE_SPI_H
#define _MAX7456_SOFTWARE_SPI_H


/* ##########################################################################
 * Software SPI to communicate with MAX7456
 * ##########################################################################*/

#define MAX_CS_HIGH             PORTA |=  (1 << PA1);
#define MAX_CS_LOW              PORTA &= ~(1 << PA1);
#define MAX_SDIN_HIGH           PORTA |=  (1 << PA2);
#define MAX_SDIN_LOW            PORTA &= ~(1 << PA2);
#define MAX_SCLK_HIGH           PORTA |=  (1 << PA3);
#define MAX_SCLK_LOW            PORTA &= ~(1 << PA3);
#define MAX_RESET_HIGH          PORTA |=  (1 << PA5);
#define MAX_RESET_LOW           PORTA &= ~(1 << PA5);

/* ##########################################################################
 * MAX7456 Register definitions
 * ##########################################################################*/


#define MAX7456_REG_READ_OFFSET 0x80

#define MAX7456_VM0             0x00
#define MAX7456_VM1             0x01
#define MAX7456_HOS             0x02
#define MAX7456_VOS             0x03
#define MAX7456_DMM             0x04
#define MAX7456_DMAH    0x05
#define MAX7456_DMAL    0x06
#define MAX7456_DMDI    0x07
#define MAX7456_CMM             0x08
#define MAX7456_CMAH    0x09
#define MAX7456_CMAL    0x0A
#define MAX7456_CMDI    0x0B
#define MAX7456_OSDM    0x0C
#define MAX7456_RB0             0x10
#define MAX7456_RB1             0x11
#define MAX7456_RB2             0x12
#define MAX7456_RB3             0x13
#define MAX7456_RB4             0x14
#define MAX7456_RB5             0x15
#define MAX7456_RB6             0x16
#define MAX7456_RB7             0x17
#define MAX7456_RB8             0x18
#define MAX7456_RB9             0x19
#define MAX7456_RB10    0x1A
#define MAX7456_RB11    0x1B
#define MAX7456_RB12    0x1C
#define MAX7456_RB13    0x1D
#define MAX7456_RB14    0x1E
#define MAX7456_RB15    0x1F
#define MAX7456_OSDBL   0x6C

// READ-ONLY REGs

#define MAX7456_STAT    0xA0
#define MAX7456_DMDO    0xB0
#define MAX7456_CMDO    0xC0


/* ##########################################################################
 * MAX7456 SPI & Display stuff
 * ##########################################################################*/


/**
 * Send a byte through SPI
 */

void spi_send(uint8_t);

/**
 *  Send <byte> to <address> of MAX7456
 */

void spi_send_byte(uint8_t, uint8_t);

/**
 *  write a <character> to <address> of MAX7456 display memory
 */

void write_char(uint16_t, char);

/**
 *  write a character <attribute> to <address> of MAX7456 display memory
 */

void write_char_att(uint16_t, char);
/**
 *  write a <character> at <x>/<y> to MAX7456 display memory
 */

void write_char_xy(uint8_t, uint8_t, char);
/**
 *  write a  character <attribute> at <x>/<y> to MAX7456 display memory
 */

void write_char_att_xy(uint8_t, uint8_t, char attribute);

/**
 *  clear display memory
 *  (also sets 8bit mode)
 */

void clear(void);

/**
 *  write an ascii <character> to <address> of MAX7456 display memory
 */

void write_ascii_char(uint16_t, char);

/**
 *  write an ascii <string> at <x>/<y> to MAX7456 display memory
 */

void write_ascii_string(uint8_t, uint8_t, char*);

/**
 *  write an ascii <string> with lenght <len> at <x>/<y> to MAX7456 display memory
 */

void write_ascii_string_len(uint8_t x, uint8_t y, char *string, uint8_t len);

/**
 *  write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory
 */

void write_ascii_string_pgm(uint8_t, uint8_t, const char*);

/**
 *  write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory
 */

void write_string_pgm_down(uint8_t, uint8_t, const char*, uint8_t);

/**
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory
 * <length> represents the length to rightbound the number
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
 */

void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);

/**
 * Write a signed <number> at <x>/<y> to MAX7456 display memory
 * <length> represents the length to rightbound the number
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
 */

void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t);

/**
 * Write a unsigned <number> at <x>/<y> to MAX7456 display memory as /10th of value
 * <length> represents the length to rightbound the number
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
 */

void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t);

/**
 * Write a signed <number> at <x>/<y> to MAX7456 display memory as /10th of value
 * <length> represents the length to rightbound the number
 * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
 */

void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t);

/**
 *  write <seconds> as human readable time at <x>/<y> to MAX7456 display mem
 */

void write_time(uint8_t, uint8_t, uint16_t);

#if (ALLCHARSDEBUG|(WRITECHARS != -1))
/**
 * for testing write all chars to screen
 */

void write_all_chars();

/**
 * let the MAX7456 learn a new character at <number>
 * with <data>.
 */

void learn_char(uint8_t, unsigned char*);
#endif

/**
 * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude
 */

void write_gps_pos(uint8_t, uint8_t, int32_t);

#endif