MSP430 ile IR uzaktan kumandalı P10 panel üzerinde sayıcı

P10 LED paneller çoğunlukla reklamcılık alanında kullanılıyor. Ucuz fiyatları ve bilgisayarda kolayca hazırlanan animasyonları nedeniyle reklamcılar tarafından tercih ediliyor. Ancak hazır kontrol kartlarının desteklemediği bir uygulama yapmak istediğinizde bu panellerin kullanımı o kadar da kolay değil.

Bu yazıda P10 panellerin nasıl çalıştığından çok MSP430G2553 işlemcisi kullanılarak nasıl sürülebildiğini anlatacağım. Hazırladığımız sürücü kütüphanesini ve kızılötesi uzaktan kumanda alıcısı kütüphanesini kullanarak ve uzaktan kumanda ve bilgisayardan kontrol edilebilen bir sayıcı uygulamasının nasıl yapıldığını da bu yazıda bulabilirsiniz.

Ferhat Yol tarafından hazırlanmış panellerin çalışma mantığı ile ilgili ayrıntılı bilgiye ve PIC kütüphanesine http://arectron.com/yazilim/p10-panel-kullanimi.html adresinden ulaşabilirsiniz. Ben bu kütüphaneyi sayı gösterecek şekilde sadeleştirip 2 panelde ayrı ayrı sayılar gösterebilecek şekilde Texas Instruments firmasının MSP430 işlemcisine uyarladım. Kütüphaneye benim eklediğim DrawDigit fonksiyonu www.freshney.org sitesinde bulunan LEDMatrixStudio uygulaması ile hazırlanan fontları gösterecek şekilde düzenlendi. Parlaklık ayarı için P10u satır satır tazeleyen ISR içine yazılımsal olarak PWM gibi davranan bir düzenleme yapmıştım ama pek verimli olmadığı için iptal ettim.

Uzaktan kumanda kütüphanesi de Arduino için hazırlanmış olan kütüphaneden uyarlanmıştır. Uyarlama sırasında rawbuf dizini 100 byte'tan 70 byte'a düşürülmüş ve integer yerine unsigned char kullanılmıştır. Bu sayede 130byte kadar ram tasarrufu sağlanmıştır.

Her iki kütüphane için de birer timer interrup'ı kullanılmıştır. Interrupt servisleri kütüphaneler içinde değil main altında bulunmaktadır. P10 kütüphanesi için herhangi bir sıkıntı yoktur ancak IR kütüphanesi için parametreleri taşıyan irparams değişkeni main altında extern ile kullanılmıştır.

Kızılötesi alıcının data pini main altında  #define IRPIN        BIT3  ile tanımlanmış ve P1.3 nolu pine bağlanmıştır. Kızılötesi alıcılar kodlarına bağlı olarak aktif HIGH veya aktif LOW olarak çalışıyor olabilrler. Eğer elinizde bir logic analyzer yoksa ir.h dosyasının altında


//#define HIGHMARK        // select this if IR receiver mark signal is HIGH

#define    LOWMARK            // select this if IR receiver mark signal is LOW

ile tanımlanan LOWMARK'ı HIGHMARK ile değiştirin. Eğer bağlantı ve kodunuzda sorun yoksa birinden biri çalışmalı.

Uygulamada uygun fiyatlı ve çok amaçlı tuş yapısına sahip olduğu için keyes uzaktan kumanda kullanıldı. Her tuşun gönderdiği değeri ir.h dosyası içinde bulabilirsiniz.

Serial ve SPI kütüphaneleri Texas Instruments'ın MSP430 launchpad ile birlikte verdiği kod örnekleri kullanılarak hazırlanmıştır.

Proje kazasız işgünü sayıcısı olarak kullanılmak üzere hazırlandı. Projenin son halinin ticari değeri olduğu için bitmiş halini değil minimum yapı ile çalışır halini burada paylaşıyorum. Dileyenler basit değişikliklerle istedikleri amaç için kullanabilirler. Projenin bitmiş hali I2C üzerinden çalışan bir de RTC desteklemektedir. Fotoğraflarda görünen kart üzerindeki pil RTC için kullanılmaktadır. Baskı devre kartı MSP430 launchpad üzerinde bulunan arayüze uyumlu olarak tasarlandığından geliştirme aşamasında launchpadin debug özelliği ve USB seri dönüştürücü özelliğinden faydalanılmıştır.

Daha fazla bilgi için

Aşağıda projeye ait dosyalar sırasıyla verilmiştir.

  • p10.h
  • font2.h
  • p10.c
  • ir.h
  • ir.c
  • serial.h
  • serial.c
  • spi.h
  • spi.c
  • stdlib.h
  • stdlib.c
  • main.h
  • main.c

P10 kütüphanesi için header dosyası p10.h


/* Filename		: p10.h
 * Created on: 10 Eki 2013
 * Author: Soner SEZGİN- www.elektronart.com
 * EXP: MSP430 driver library for P10 LED panel 32x16px
 *
 *
 * Modified and limited version of
 * File Name          : P10_Panel_Driver.c
 * Author             : Ferhat YOL
 * Version            : V1.0
 * Date               : 13/07/2013
 * Description        : P10 Panel kütüphanesidir
 *
 * see http://arectron.com/yazilim/p10-panel-kullanimi.html for more info of source library.
 *
 */
#ifndef P10_H_
#define P10_H_

#define PANELNUM	1
#define PANELWDT	32
#define PANELHGT	16
#define Font1H		8
#define Font2H		12
#define Font3H		14
#define Font4H		16

#define WIDTH		PANELNUM*PANELWDT - 1
#define HEIGHT		PANELHGT - 1

#define PANEL1		0
//#define PANEL2

void write_data(int row_adr);
void P10_Init(void);
void ShowString(unsigned int x, unsigned int y, unsigned int size, int fill);
int LineScroll(unsigned int Line, int ZeroBit);
void ScrollTextFont2(unsigned int Line, unsigned int Speed,int fill);
void TextToLeftScroll(unsigned int Line, unsigned int Size, unsigned int Speed,int fill);
void P10_Clear(void);
void P10_Fill(void);
void P10_SetText (char* Text);
void P10_ClearText(void);
void P10_DisplayCount(unsigned int count, unsigned char fontsize);

#endif /* P10_H_ */
 

P10 için karakter ve rakam fontları


//FontSize : 8 x 12
#ifndef FONT2_H_
#define FONT2_H_

const unsigned char Digits[11][16] = {
		0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	, 0x00	,  // Code for char
		0x7F	, 0xE0	, 0xFF	, 0xF0	, 0xC0	, 0x30	, 0xC0	, 0x30	, 0xC0	, 0x30	, 0xFF	, 0xF0	, 0x7F	, 0xE0	, 0x00	, 0x00	,
		0x00	, 0x0	, 0x60	, 0x30	, 0xE0	, 0x30	, 0xFF	, 0xF0	, 0xFF	, 0xF0	, 0x00	, 0x30	, 0x00	, 0x30	, 0x00	, 0x00	,
		0x70	, 0x70	, 0xF0	, 0xF0	, 0xC1	, 0xF0	, 0xC3	, 0xB0	, 0xC7	, 0x30	, 0xFE	, 0x30	, 0x7C	, 0x30	, 0x00	, 0x00	,
		0x60	, 0x60	, 0xE6	, 0x70	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xFF	, 0xF0	, 0x7D	, 0xE0	, 0x00	, 0x00	,
		0x0F	, 0x80	, 0x1F	, 0x80	, 0x39	, 0x80	, 0x71	, 0x80	, 0xFF	, 0xF0	, 0xFF	, 0xF0	, 0x01	, 0x80	, 0x00	, 0x00	,
		0xFC	, 0x30	, 0xFC	, 0x30	, 0xCC	, 0x30	, 0xCC	, 0x30	, 0xCC	, 0x30	, 0xCF	, 0xF0	, 0xC7	, 0xE0	, 0x00	, 0x00	,
		0x7F	, 0xE0	, 0xFF	, 0xF0	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xE7	, 0xF0	, 0x63	, 0xE0	, 0x00	, 0x00	,
		0xE0	, 0x0	, 0xE0	, 0xF0	, 0xC1	, 0xF0	, 0xC3	, 0x80	, 0xC7	, 0x0	, 0xFE	, 0x0	, 0xFC	, 0x0	, 0x00	, 0x00	,
		0x7D	, 0xE0	, 0xFF	, 0xF0	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xFF	, 0xF0	, 0x7D	, 0xE0	, 0x00	, 0x00	,
		0x7C	, 0x60	, 0xFE	, 0x70	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xC6	, 0x30	, 0xFF	, 0xF0	, 0x7F	, 0xE0	, 0x00	, 0x00
};

const unsigned char Font_8x12[96][16] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char  
        0x00, 0x00, 0x7E, 0x03, 0x7E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char !
        0x1E, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char "
        0xC0, 0x00, 0xD8, 0x03, 0xF8, 0x00, 0xDE, 0x00, 0xD8, 0x03, 0xF8, 0x00, 0xDE, 0x00, 0x18, 0x00,  // Code for char #
        0x1C, 0x01, 0x3E, 0x02, 0x22, 0x02, 0xFF, 0x07, 0x22, 0x02, 0xE2, 0x03, 0xC4, 0x01, 0x00, 0x00,  // Code for char $
        0x0C, 0x06, 0x92, 0x03, 0xCC, 0x00, 0x60, 0x00, 0x30, 0x03, 0x98, 0x04, 0x0E, 0x03, 0x00, 0x00,  // Code for char %
        0xDC, 0x01, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 0x7E, 0x02, 0xDC, 0x01, 0x00, 0x03, 0x80, 0x04,  // Code for char &
        0x00, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char '
        0x00, 0x00, 0xFC, 0x01, 0xFE, 0x03, 0x03, 0x06, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char (
        0x00, 0x00, 0x01, 0x04, 0x03, 0x06, 0xFE, 0x03, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char )
        0x00, 0x00, 0x14, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00,  // Code for char *
        0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,  // Code for char +
        0x00, 0x08, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ,
        0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char -
        0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char .
        0x00, 0x08, 0x00, 0x06, 0x80, 0x01, 0x60, 0x00, 0x18, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char /
        0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x03, 0xFC, 0x01, 0x00, 0x00,  // Code for char 0
        0x00, 0x00, 0x04, 0x02, 0x04, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00,  // Code for char 1
        0x0C, 0x02, 0x02, 0x03, 0x82, 0x03, 0xC2, 0x02, 0x62, 0x02, 0x3E, 0x02, 0x1C, 0x02, 0x00, 0x00,  // Code for char 2
        0x04, 0x01, 0x02, 0x02, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x00, 0x00,  // Code for char 3
        0x60, 0x00, 0x50, 0x00, 0x48, 0x00, 0x44, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x40, 0x00, 0x00, 0x00,  // Code for char 4
        0x1E, 0x01, 0x1E, 0x02, 0x12, 0x02, 0x12, 0x02, 0x12, 0x02, 0xF2, 0x03, 0xE2, 0x01, 0x00, 0x00,  // Code for char 5
        0xFC, 0x01, 0xFE, 0x03, 0x12, 0x02, 0x12, 0x02, 0x12, 0x02, 0xF2, 0x03, 0xE4, 0x01, 0x00, 0x00,  // Code for char 6
        0x02, 0x00, 0x02, 0x00, 0x82, 0x03, 0xE2, 0x03, 0x7A, 0x00, 0x1E, 0x00, 0x06, 0x00, 0x00, 0x00,  // Code for char 7
        0xDC, 0x01, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x00, 0x00,  // Code for char 8
        0x3C, 0x00, 0x7E, 0x02, 0x42, 0x02, 0x42, 0x02, 0x42, 0x03, 0xFE, 0x01, 0xFC, 0x00, 0x00, 0x00,  // Code for char 9
        0x00, 0x00, 0x18, 0x03, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char :
        0x00, 0x04, 0x18, 0x07, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ;
        0x60, 0x00, 0x60, 0x00, 0x90, 0x00, 0x90, 0x00, 0x08, 0x01, 0x08, 0x01, 0x04, 0x02, 0x00, 0x00,  // Code for char <
        0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x00, 0x00,  // Code for char =
        0x04, 0x02, 0x04, 0x02, 0x08, 0x01, 0x08, 0x01, 0x90, 0x00, 0x90, 0x00, 0x60, 0x00, 0x00, 0x00,  // Code for char >
        0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x62, 0x03, 0x72, 0x03, 0x1E, 0x00, 0x0C, 0x00, 0x00, 0x00,  // Code for char ?
        0xF8, 0x00, 0x04, 0x01, 0x72, 0x02, 0x8A, 0x02, 0x8A, 0x02, 0xF2, 0x02, 0x86, 0x02, 0x7C, 0x01,  // Code for char @
        0xF8, 0x03, 0xFC, 0x03, 0x46, 0x00, 0x46, 0x00, 0x46, 0x00, 0xFC, 0x03, 0xF8, 0x03, 0x00, 0x00,  // Code for char A
        0xFE, 0x03, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x00, 0x00,  // Code for char B
        0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x8C, 0x01, 0x00, 0x00,  // Code for char C
        0xFE, 0x03, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0xFC, 0x01, 0xF8, 0x00, 0x00, 0x00,  // Code for char D
        0xFE, 0x03, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,  // Code for char E
        0xFE, 0x03, 0xFE, 0x03, 0x22, 0x00, 0x22, 0x00, 0x22, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char F
        0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x22, 0x02, 0xE2, 0x03, 0xEC, 0x03, 0x00, 0x00,  // Code for char G
        0xFE, 0x03, 0xFE, 0x03, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x00, 0x00,  // Code for char H
        0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,  // Code for char I
        0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char J
        0xFE, 0x03, 0xFE, 0x03, 0x70, 0x00, 0xD8, 0x00, 0x8C, 0x01, 0x06, 0x03, 0x02, 0x02, 0x00, 0x00,  // Code for char K
        0xFE, 0x03, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,  // Code for char L
        0xFE, 0x03, 0x1C, 0x00, 0x30, 0x00, 0x40, 0x00, 0x30, 0x00, 0x1C, 0x00, 0xFE, 0x03, 0x00, 0x00,  // Code for char M
        0xFE, 0x03, 0x06, 0x00, 0x1E, 0x00, 0x78, 0x00, 0xE0, 0x01, 0x80, 0x03, 0xFE, 0x03, 0x00, 0x00,  // Code for char N
        0xFC, 0x01, 0xFE, 0x03, 0x06, 0x03, 0x06, 0x03, 0x06, 0x03, 0xFE, 0x03, 0xFC, 0x01, 0x00, 0x00,  // Code for char O
        0xFE, 0x03, 0xFE, 0x03, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x7E, 0x00, 0x3C, 0x00, 0x00, 0x00,  // Code for char P
        0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0xFE, 0x07, 0xFC, 0x05,  // Code for char Q
        0xFE, 0x03, 0xFE, 0x03, 0x22, 0x00, 0x62, 0x00, 0xE2, 0x00, 0xBE, 0x03, 0x1C, 0x02, 0x00, 0x00,  // Code for char R
        0x9C, 0x01, 0x3E, 0x02, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xE2, 0x03, 0xCC, 0x01, 0x00, 0x00,  // Code for char S
        0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,  // Code for char T
        0xFE, 0x01, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0xFE, 0x03, 0xFE, 0x01, 0x00, 0x00,  // Code for char U
        0x7E, 0x00, 0xC0, 0x00, 0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0x7E, 0x00,  // Code for char V
        0xFE, 0x03, 0x00, 0x03, 0x80, 0x01, 0xF0, 0x00, 0xF0, 0x00, 0x80, 0x01, 0x00, 0x03, 0xFE, 0x03,  // Code for char W
        0x06, 0x03, 0x8E, 0x03, 0xD8, 0x00, 0x70, 0x00, 0x70, 0x00, 0xD8, 0x00, 0x8E, 0x03, 0x06, 0x03,  // Code for char X
        0x06, 0x00, 0x1E, 0x00, 0x38, 0x00, 0xE0, 0x03, 0xE0, 0x03, 0x38, 0x00, 0x1E, 0x00, 0x06, 0x00,  // Code for char Y
        0x02, 0x03, 0x82, 0x03, 0xC2, 0x02, 0x62, 0x02, 0x32, 0x02, 0x1A, 0x02, 0x0E, 0x02, 0x00, 0x00,  // Code for char Z
        0x00, 0x00, 0xFE, 0x07, 0xFE, 0x07, 0x02, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char [
        0x06, 0x00, 0x18, 0x00, 0x60, 0x00, 0x80, 0x01, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,  // Code for char BackSlash
        0x00, 0x00, 0x02, 0x04, 0x02, 0x04, 0xFE, 0x07, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ]
        0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00,  // Code for char ^
        0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,  // Code for char _
        0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char `
        0x00, 0x03, 0xA0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0xE0, 0x07, 0x00, 0x00,  // Code for char a
        0xFE, 0x07, 0xFE, 0x07, 0x20, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0xE0, 0x03, 0x00, 0x00,  // Code for char b
        0xE0, 0x03, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00,  // Code for char c
        0xE0, 0x03, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x02, 0xFE, 0x07, 0xFE, 0x07, 0x00, 0x00,  // Code for char d
        0xE0, 0x03, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x04, 0xE0, 0x02, 0x00, 0x00,  // Code for char e
        0x10, 0x00, 0xFC, 0x07, 0xFE, 0x07, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char f
        0x7C, 0x02, 0xFE, 0x04, 0x82, 0x04, 0x82, 0x04, 0x42, 0x04, 0xFE, 0x07, 0xFE, 0x03, 0x00, 0x00,  // Code for char g
        0xFE, 0x07, 0xFE, 0x07, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0xE0, 0x07, 0x00, 0x00,  // Code for char h
        0xF6, 0x07, 0xF6, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char i
        0x00, 0x00, 0x10, 0x00, 0xF6, 0x07, 0xF6, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char j
        0xFE, 0x07, 0xFE, 0x07, 0xC0, 0x01, 0x60, 0x03, 0x30, 0x06, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00,  // Code for char k
        0xFE, 0x07, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char l
        0xE0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07, 0xE0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07,  // Code for char m
        0xF0, 0x07, 0xF0, 0x07, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0xE0, 0x07, 0x00, 0x00,  // Code for char n
        0xE0, 0x03, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0xE0, 0x03, 0x00, 0x00,  // Code for char o
        0xFE, 0x07, 0xFE, 0x07, 0x84, 0x00, 0x82, 0x00, 0x82, 0x00, 0xFE, 0x00, 0x7C, 0x00, 0x00, 0x00,  // Code for char p
        0x7C, 0x00, 0xFE, 0x00, 0x82, 0x00, 0x82, 0x00, 0x42, 0x00, 0xFE, 0x07, 0xFE, 0x07, 0x00, 0x00,  // Code for char q
        0xF0, 0x07, 0xF0, 0x07, 0x20, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char r
        0x60, 0x02, 0xF0, 0x04, 0xD0, 0x04, 0x90, 0x05, 0x90, 0x07, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00,  // Code for char s
        0x10, 0x00, 0xFC, 0x03, 0xFC, 0x07, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char t
        0xF0, 0x03, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x02, 0xF0, 0x07, 0xF0, 0x07, 0x00, 0x00,  // Code for char u
        0x70, 0x00, 0xF0, 0x01, 0x80, 0x07, 0x00, 0x06, 0x80, 0x07, 0xF0, 0x01, 0x70, 0x00, 0x00, 0x00,  // Code for char v
        0xF0, 0x03, 0x00, 0x06, 0x00, 0x04, 0xE0, 0x03, 0x00, 0x04, 0x00, 0x06, 0xF0, 0x03, 0x00, 0x00,  // Code for char w
        0x30, 0x06, 0x70, 0x07, 0xC0, 0x01, 0xC0, 0x01, 0x70, 0x07, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00,  // Code for char x
        0x18, 0x02, 0x30, 0x04, 0x60, 0x04, 0xC0, 0x07, 0xC0, 0x03, 0x60, 0x00, 0x38, 0x00, 0x00, 0x00,  // Code for char y
        0x10, 0x06, 0x10, 0x07, 0x90, 0x05, 0xD0, 0x04, 0x70, 0x04, 0x30, 0x04, 0x00, 0x00, 0x00, 0x00,  // Code for char z
        0x60, 0x00, 0xFC, 0x03, 0x9E, 0x07, 0x02, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char {
        0x00, 0x00, 0x00, 0x00, 0xFE, 0x07, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char |
        0x02, 0x04, 0x02, 0x04, 0x9E, 0x07, 0xFC, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char }
        0xE0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x70, 0x00,  // Code for char ~
        0x00, 0x00, 0xFE, 0x07, 0x02, 0x04, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // Code for char 
        };

#endif

P10 kütüphanesi için kaynak kod dosyası p10.c


/* Filename		: P10.c
 * Created on	: 10 Eki 2013
 * Author		: Soner SEZGİN - www.elektronart.com
 * EXP			: MSP430 driver library for P10 LED panel 32x16px or 64x16px
 * Modified and limited version of
 *
 * File Name          : P10_Panel_Driver.c
 * Author             : Ferhat YOL
 * Version            : V1.0
 * Date               : 13/07/2013
 * Description        : P10 Panel kütüphanesidir
 *
 * see http://arectron.com/yazilim/p10-panel-kullanimi.html for more info of source library.
 *
 */

#include 
#include "p10.h"
#include "spi.h"
#include "font2.h"
#include "stdlib.h"


unsigned char display_ram[16][4];        // For 1 P10 panel in standalone
char P10_Text[20];


// For 1 P10 panel in standalone
void write_data(int row_adr)
{
   int i=0,j=0;
   int k=4;

   while(k){
   j=16-k;
     for (i=0;i<4;i++)
     {
       spi_send_byte(display_ram[j][row_adr]);
       j-=4;
     }
     k--;
   }

}

void P10_Init(void){

	P2OUT |= LATCH;
	P2OUT &= ~0x03;
	P2OUT |= OE;		//disable OE
}

void PutPixel(unsigned int Xpos,unsigned int Ypos, int fill)
{
  unsigned int y1,x1;
  unsigned int y2,x2;
  int temp=0;

  y1 = Ypos%4;
  y2 = Ypos/4;
  x1 = Xpos%8;
  x2 = Xpos/8;

  if(fill)  //Nokta Koy
  {
    temp=display_ram[(y2*4)+x2][y1]; //Ram'deki değer ön belleğe alınıyor.
    display_ram[(y2*4)+x2][y1] = (temp & (255-(128>>x1))); //x'inci bit 0 yapılır
  }
  else     //Noktayı Sil
  {
    temp=display_ram[(y2*4)+x2][y1]; //Ram'deki değer ön belleğe alınıyor.
    display_ram[(y2*4)+x2][y1] = (temp | (128>>x1)); //x'inci Bit 1 yapılır
  }

}


//Added to library to display numbers generated by LEDMatrixStudio
//www.freshney.org // paul@freshney.org
void DrawDigit(unsigned int x, unsigned int y, int fill){
unsigned int a=0,b=0,i=0;
unsigned int cdata=0;
unsigned int clm=x,row=y;

  while(P10_Text[i]!='\0')
  {
      if(clm+7>WIDTH)
      {
        clm=0;
        row=row+12;
        if(row+12>HEIGHT+1) break;
      }

       for(b=0;b<16;b=b+2)
       {
         cdata=Digits[(unsigned int)(P10_Text[i]-47)][b];
         for(a=0;a<8;a++)
         {
           PutPixel(clm+(b/2),row+a,(fill-(cdata>>(7-a)) & 0x01));
         }
         cdata=Digits[(unsigned int)(P10_Text[i]-47)][b+1];
         for(a=0;a<4;a++)
         {
           PutPixel(clm+(b/2),row+8+a,(fill-(cdata>>(7-a)) & 0x01));
         }
       }
     clm=clm+8;
     i++;
  }
}

void DrawCharFont2(unsigned int x, unsigned int y, int fill){
unsigned int a=0,b=0,i=0;
unsigned int cdata=0;
unsigned int clm=x,row=y;

  while(P10_Text[i]!='\0')
  {
      if(clm+7>WIDTH)  //Satır sonuna gelindimi Bir Alt Satıra Geç
      {
        clm=0;
        row=row+12;
        if(row+12>HEIGHT+1) break;
      }

       for(b=0;b<16;b=b+2)
       {
         cdata=Font_8x12[(unsigned int)(P10_Text[i]-32)][b];
         for(a=0;a<8;a++)
         {
           PutPixel(clm+(b/2),row+a,(fill-(cdata>>a) & 0x01));
         }
         cdata=Font_8x12[(unsigned int)(P10_Text[i]-32)][b+1];
         for(a=0;a<4;a++)
         {
           PutPixel(clm+(b/2),row+8+a,(fill-(cdata>>a) & 0x01));
         }
       }
     clm=clm+8;
     i++;
  }
}


void ShowString(unsigned int x, unsigned int y, unsigned int size, int fill){
  switch(size)
  {
    case 2:
    	DrawCharFont2(x,y,fill);
    	break;
    case 3:
    	DrawDigit(x,y,fill);
    	break;
    default:
    	break;
  }
}

int LineScroll(unsigned int Line, int ZeroBit){
  unsigned long Tam=0;
  unsigned int y1=Line%4;
  unsigned int y2=Line/4;
  int OwerFlow;
  ZeroBit=1-ZeroBit;

  OwerFlow=(display_ram[(y2*4)][y1]/128)&0x01;
  Tam=display_ram[(y2*4)][y1];
  Tam=Tam<<8;
  Tam=Tam+display_ram[(y2*4)+1][y1];
  Tam=Tam<<8;
  Tam=Tam+display_ram[(y2*4)+2][y1];
  Tam=Tam<<8;
  Tam=Tam+display_ram[(y2*4)+3][y1];

  Tam=Tam<<1;
  Tam=Tam+ZeroBit;

  display_ram[(y2*4)  ][y1]=(long)(Tam>>24)&0xFF;
  display_ram[(y2*4)+1][y1]=(long)(Tam>>16)&0xFF;
  display_ram[(y2*4)+2][y1]=(long)(Tam>>8)&0xFF;
  display_ram[(y2*4)+3][y1]=(long)(Tam&0xFF);

  return OwerFlow;
}


void ScrollDigits2(unsigned int Line, unsigned int Speed,int fill){
  unsigned int a=0,b=0,i=0;
  unsigned int cdata=0;
  unsigned int delay;
  unsigned int sayac=0;
  int ZeroBit=0;

  delay=Speed*20;

  while(P10_Text[i]!='\0')
  {
    if(Line+12>HEIGHT+1) break;
    for(b=0;b<16;b=b+2)
    {
       cdata=Digits[(unsigned int)(P10_Text[i]-47)][b];
       for(a=0;a<8;a++)
       {
         ZeroBit=fill-(cdata>>(7-a)) & 0x01;
         LineScroll(Line+a,ZeroBit);
       }
       cdata=Digits[(unsigned int)(P10_Text[i]-47)][b+1];
       for(a=0;a<4;a++)
       {
         ZeroBit=fill-(cdata>>(7-a)) & 0x01;
         LineScroll(Line+8+a,ZeroBit);
       }
       for(sayac=0;sayac<220-delay;sayac++)
       {
         msleep(4);
       }
    }
    i++;
  }
}

void ScrollTextFont2(unsigned int Line, unsigned int Speed,int fill){
  unsigned int a=0,b=0,i=0;
  unsigned int cdata=0;
  unsigned int delay;
  unsigned int sayac=0;
  int ZeroBit=0;

  delay=Speed*20;

  while(P10_Text[i]!='\0')
  {
    if(Line+Font2H-1>HEIGHT) break;
    for(b=0;b<16;b=b+2)
    {
       cdata=Font_8x12[(unsigned int)(P10_Text[i]-32)][b];
       for(a=0;a<8;a++)
       {
         ZeroBit=fill-(cdata>>a) & 0x01;
         LineScroll(Line+a,ZeroBit);
       }
       cdata=Font_8x12[(unsigned int)(P10_Text[i]-32)][b+1];
       for(a=0;a<4;a++)
       {
         ZeroBit=fill-(cdata>>a) & 0x01;
         LineScroll(Line+8+a,ZeroBit);
       }
       for(sayac=0;sayac<220-delay;sayac++)
       {
         msleep(4);
       }
    }
    i++;
  }
}

void TextToLeftScroll(unsigned int Line, unsigned int size, unsigned int Speed,int fill){
   switch (size)
   {
     case 2:
    	 ScrollTextFont2(Line,Speed,fill);
    	 break;
     case 3:
    	 ScrollDigits2(Line,Speed,fill);
    	 break;
     default:
    	 break;
   }
}

void P10_Clear(void){
	unsigned int i;
	for(i=0;i<16;i++) {

		display_ram[i][0] = 0xFF;
		display_ram[i][1] = 0xFF;
		display_ram[i][2] = 0xFF;
		display_ram[i][3] = 0xFF;
	}
}

void P10_Fill(void){
	int i;
	for(i=0;i<16;i++) {
		display_ram[i][0] = 0x00;
		display_ram[i][1] = 0x00;
		display_ram[i][2] = 0x00;
		display_ram[i][3] = 0x00;
	}
}

void P10_SetText (char* Text){
	char* P10_t;

	P10_t = P10_Text;

	while(*Text != '\0'){
		*P10_t = *Text;
		P10_t++;
		Text++;
	}
	*P10_t = *Text;
}

void P10_ClearText(void){
	unsigned char i=10;
	char* P10_t;

	P10_t = P10_Text;
	while(i--){
		*P10_t = '\0';
		P10_t++;
	}
}

void P10_DisplayCount(unsigned int count, unsigned char fontsize){
	char text[5];

	itoa(count,text);
	P10_SetText(text);
	P10_Clear();
	ShowString(32 - strlen(text)*8 ,2,fontsize,0);
}

Kızılötesi kütüphanesi için header dosyası ir.h


/* Filename		: ir.h
 * Created on	: 23 Eki 2013
 * Author		: Soner SEZGİN- www.elektronart.com
 *
 * EXP: MSP430 driver library header for IR receiver with internal demodulator
 * Adapted from Arduino library, optimized for MSP430, use 130byte less ram
 * Transmit part is canceled completely and receiver part is minimized only for NEC
 * IR_RecvIsr() moved to timer ISR under main.
 *
 * ORIGINAL
 * #define RAWBUF 100 // Length of raw duration buffer
 * unsigned int rawbuf[RAWBUF]; // raw data

 * ADAPTED
 * #define RAWBUF 70 // Length of raw duration buffer
 * unsigned char rawbuf[RAWBUF]; // raw data
 *
 * IRremote
 * Version 0.11 August, 2009
 * Copyright 2009 Ken Shirriff
 * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
 *
 * Modified by Paul Stoffregen  to support other boards and timers
 * Modified  by Mitra Ardron 
 * Added Sanyo and Mitsubishi controllers
 * Modified Sony to spot the repeat codes that some Sony's send
 *
 * Interrupt code based on NECIRrcv by Joe Knapp
 * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
 * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
 *
 * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
 */

#ifndef IR_H_
#define IR_H_

//#define HIGHMARK		// select this if IR receiver mark signal is HIGH
#define	LOWMARK			// select this if IR receiver mark signal is LOW

#define IR_UP 		0x00FF629D
#define IR_DOWN		0x00FFA857
#define IR_RIGHT	0x00FFC23D
#define IR_LEFT		0x00FF22DD
#define IR_OK		0x00FF02FD
#define IR_ZERO		0x00FF4AB5
#define	IR_STAR		0x00FF42BD
#define	IR_DASH		0x00FF52AD
#define IR_ONE		0x00FF6897
#define IR_TWO		0x00FF9867
#define	IR_THREE	0x00FFB04F
#define	IR_FOUR		0x00FF30CF
#define	IR_FIVE		0x00FF18E7
#define	IR_SIX		0x00FF7A85
#define IR_SEVEN	0x00FF10EF
#define	IR_EIGHT	0x00FF38C7
#define IR_NINE		0x00FF5AA5

#define NEC 1
#define SONY 2
#define RC5 3
#define RC6 4
#define DISH 5
#define SHARP 6
#define UNKNOWN -1
// Decoded value for NEC when a repeat code is received
#define REPEAT 0xffffffff

#define LTOL (1.0 - TOLERANCE/100.)
#define UTOL (1.0 + TOLERANCE/100.)

#define _GAP 5000 // Minimum map between transmissions
#define GAP_TICKS (_GAP/USECPERTICK)

#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))

#define MARK_EXCESS 200
#define USECPERTICK 50
#define RAWBUF 70 // Length of raw duration buffer

// receiver states
#define STATE_IDLE     2
#define STATE_MARK     3
#define STATE_SPACE    4
#define STATE_STOP     5

#ifdef	LOWMARK
#define MARK  0		// depending on the IR receiver, 1 if MARK represented by HIGH
#define SPACE 1		// depending on the IR receiver, 0 if SPACE represented by LOW
#endif

#ifdef	HIGHMARK
#define MARK  1		// depending on the IR receiver, 1 if MARK represented by HIGH
#define SPACE 0		// depending on the IR receiver, 0 if SPACE represented by LOW
#endif

#define TOLERANCE 30  // percent tolerance in measurements

#define ERR 0
#define DECODED 1

typedef struct {
  int decode_type; // NEC, SONY, RC5, UNKNOWN
  unsigned long value; // Decoded value
  int bits; // Number of bits in decoded value
  volatile unsigned char *rawbuf; // Raw intervals in .5 us ticks
  int rawlen; // Number of records in rawbuf.
}decode_results;

typedef struct {
  char recvpin;             // pin for IR data from detector
  char rcvstate;            // state machine
  char blinkflag;           // TRUE to enable blinking of GREEN_LED on IR processing
  char rawlen;              // counter of entries in rawbuf
  unsigned int timer;          // state timer, counts 50uS ticks.
  unsigned char rawbuf[RAWBUF]; // raw data
}
irparams_t;

void 	IR_SetInPin(int recvpin);
void 	IR_EnableIn(void);
void 	IR_resume();
int 	IR_Decode(decode_results *results);
long 	IR_DecodeNEC(decode_results *results);

#endif /* IR_H_ */

Kızılötesi kütüphanesi için kaynak kod dosyası ir.c


/* Filename		: ir.c
 * Created on	: 23 Eki 2013
 * Author		: Soner SEZGİN- www.elektronart.com
 * EXP: MSP430 driver library source for IR receiver with internal demodulator
 *
 * Adapted from arduino IR library.
 * IRremote
 * Version 0.11 August, 2009
 * Copyright 2009 Ken Shirriff
 * See header definition for more information.
*/

#include 
#include "ir.h"

// pulse parameters in usec
#define NEC_HDR_MARK	9000
#define NEC_HDR_SPACE	4500
#define NEC_BIT_MARK	560
#define NEC_ONE_SPACE	1690
#define NEC_ZERO_SPACE	560
#define NEC_RPT_SPACE	2250

#define NEC_BITS 32

irparams_t irparams;

void IR_SetInPin(int recvpin)
{
  irparams.recvpin = recvpin;
  irparams.blinkflag = 0;
}

void IR_EnableIn(void) {

  // initialize state machine variables
  irparams.rcvstate = STATE_IDLE;
  irparams.rawlen = 0;

  // set pin modes
  P1DIR &= ~irparams.recvpin;		// Set IR receive pin Input
}

int MATCH(unsigned char measured, int desired) {
  return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);
}

int MATCH_MARK(unsigned char measured_ticks, int desired_us) {
  return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); // SH 071112 + -> - in TICKS_LOW
}

int MATCH_SPACE(unsigned char measured_ticks, int desired_us) {
  return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); // SH 071112 - -> + in TICKS_HIGH
}

void IR_resume() {
  irparams.rcvstate = STATE_IDLE;
  irparams.rawlen = 0;
  __enable_interrupt();
}

int IR_Decode(decode_results *results) {

  results->rawbuf = irparams.rawbuf;
  results->rawlen = irparams.rawlen;

  if (irparams.rcvstate != STATE_STOP) {
    return ERR;
  }

  __disable_interrupt();

  if (IR_DecodeNEC(results)) {
    return DECODED;
  }

  IR_resume();
  return ERR;
}

long IR_DecodeNEC(decode_results *results) {
	int i;
	long data = 0;
  int offset = 0;

  // Initial mark
  if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) {
    return ERR;
  }
  offset++;
  // Check for repeat
  if (irparams.rawlen == 3 &&
    MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) &&
    MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) {
    results->bits = 0;
    results->value = REPEAT;
    results->decode_type = NEC;
    return DECODED;
  }
  if (irparams.rawlen < 2 * NEC_BITS + 3) {
    return ERR;
  }
  // Initial space
  if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) {
    return ERR;
  }
  offset++;
  for (i = 0; i < NEC_BITS; i++) {
    if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) {
      return ERR;
    }
    offset++;
    if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) {
      data = (data << 1) | 1;
    }
    else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) {
      data <<= 1;
    }
    else {
      return ERR;
    }
    offset++;
  }
  // Success
  results->bits = NEC_BITS;
  results->value = data;
  results->decode_type = NEC;
  return DECODED;
}

Bilgisayardan kontrol için seri port header dosyası serial.h


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN-
 * EXP: MSP430 library header for Serial UART
 */
#ifndef SERIAL_H_
#define SERIAL_H_

#define RXD		BIT1	// Receive Data (RXD) at P1.1
#define TXD		BIT2	// Transmit Data (TXD) at P1.2

#define ENT		"\r\n"

void uart_init(void);
void uart_putc(unsigned char c);
void uart_puts(const char *str);
void uart_puta(const char *str, int len);


#endif /* SERIAL_H_ */

Bilgisayardan kontrol için seri port kaynak kod dosyası serial.c


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN-
 * EXP: MSP430 library source for Serial UART
 */

#include 
#include "serial.h"


void uart_init(void)
{
	P1SEL  |= RXD + TXD;
  	P1SEL2 |= RXD + TXD;
  	UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  	UCA0BR0 = 52;                            // 1MHz 9600
//  	UCA0BR1 = 3;                         // 1MHz 9600
  	UCA0MCTL = UCBRF_1|UCOS16;                 // Modulation UCBRSx = 1
  	UCA0CTL1 &= ~UCSWRST;                     // Initialize USCI state machine
    IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
}

void uart_putc(unsigned char c)
{
	while (!(IFG2&UCA0TXIFG));              // USCI_A0 TX buffer ready?
  	UCA0TXBUF = c;                    		// TX
}

void uart_puts(const char *str)
{
     while(*str) uart_putc(*str++);
}

void uart_puta(const char *str, int len)
{
     while(len--) uart_putc(*str++);
}

P10 panele veri göndermek için SPI kütüphanesi header dosyası spi.h


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN-
 * EXP: MSP430 library header for SPI
 */

#ifndef SPI_H_
#define SPI_H_

#define SCLK    BIT5
#define SOMI    BIT6	// SPI SOMI (Slave Out, Master In) at P1.6
#define SIMO    BIT7	// SPI SIMO (Slave In, Master Out) at P1.7
#define OE      BIT3	// CS (Chip Select) at P2.3
#define ADD_A	BIT0	// ROW Address A at P2.0
#define ADD_B	BIT1	// ROW Address B at P2.1
#define LATCH	BIT2	// ROW Address B at P2.2

void spi_init (void);
void spi_send_byte(char spi_data);
void spi_send_buf(char* spi_data, int len);

#endif /* SPI_H_ */

P10 panele veri gönderebilmek için SPI kütüphanesi kaynak kod dosyası spi.c


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN-
 * EXP: MSP430 library source for SPI
 */

#include 
#include "spi.h"

void spi_init (void){

	UCB0CTL1 = UCSWRST;
  	P1SEL  |= SOMI + SIMO + SCLK;
  	P1SEL2 |= SOMI + SIMO + SCLK;
    // (3) 3-pin, 8-bit SPI master
    UCB0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC;
	UCB0CTL1 |= UCSSEL_2;   // SMCLK
	UCB0CTL1 &= ~UCSWRST;
	P2OUT |= OE;
}

void spi_send_byte(char spi_data){

	UCB0TXBUF = spi_data;						// Veriyi yükle
    while (!(IFG2 & UCB0TXIFG));              // USCI_A0 TX buffer ready?

}

void spi_send_buf(char* spi_data, int len){
	int i;
	for(i=0;i

 

Genel standart kütüphane header dosyası stdlib.h


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN- www.elektronart.com
 * EXP: MSP430 standard library with useful tools
 */

#ifndef STDLIB_H_
#define STDLIB_H_

void usleep(unsigned int tick);
void msleep(unsigned int tick);
void h2a(char h, char* a);
void itoa(int n, char* s);
char atoi(char *s);
int strlen(char* str);

#endif /* STDLIB_H_ */

 

Genel standart kütüphane kaynak kod dosyası stdlib.c


/* Created on: 10 Eki 2013
 * Author: Soner SEZGİN- www.elektronart.com
 * EXP: MSP430 standard library with useful tools
 */
#include 

void usleep(unsigned int tick){
	int i;
	for(i=0;i3) break;
    } while ((n /= 10) > 0);     /* delete it */

//    if (sign < 0)
//        s[i++] = '-';

    s[i] = '\0';

    if(i>1) reverse(&s[0],i);
}

char atoi(char *s){
 unsigned char i, n;

 n = 0;
 for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
 n = 10 * n + (s[i] - '0');
 return n;
}

void h2a(char h, char* a){
	char t;

	t=h>>4;
	t &= 0x0F;

	if(t>9) *a = t-10 + 'A';
	else 	*a = t+ '0';

	t= h & 0x0F;
	a++;
	if(t>9) *a = t-10 + 'A';
	else 	*a = t+ '0';
	*(a+1) = '\0';

}

int strlen(char* str){
	    int len = 0;
	    while (*str != '\0') {
	        str++;
	        len++;
	    }
	    return len;
}

 

Kütüphaneleri tets için main program header main.h


/*
 * Filename:	main.h
 * Created on:	10 Eki 2013
 * Author: 		Soner SEZGİN- www.elektronart.com
  * EXP: Main process for P10 LED panel driver 32x16px or 64x16px
 * Code written for MSP430G2553. Program displays 1 counter
 * on a P10 display. Counter is controlled by remote controller in NEC protocol.
 * In order to reduce code size, other protocols are disabled.
 * Remote controller receiver connected to BIT3 on port 1.
 * P10 control signals are as follows
 * P10_A		->	P2.0
 * P10_B		->	P2.1
 * P10_LATCH	->	P2.2
 * P10_OE		->	P2.3
 * P10_CLK		->	P1.5	(SPICLK)
 * P10_DATA		->	P1.7	(SPIMOSI)
 */

#ifndef MAIN_H_
#define MAIN_H_

#include "ir.h"

#define ON			1
#define OFF			0

#define IRPERIOD	50		//usec
#define P10PERIOD	2500	//usec
#define CPUCLOCK	8		//8 MHZ

#define TIMER_IR	CPUCLOCK * IRPERIOD
#define	TIMER_P10	CPUCLOCK * P10PERIOD

#define PANEL_ROW			1
#define PANEL_COLUMN		1

void IR_Process(decode_results *results);
void Serial_Process(void);

#endif /* MAIN_H_ */

 

Kütüphaneleri test için main program kaynak kod main.c


/*
 * Filename:	main.c
 * Created on:	10 Eki 2013
 * Author:		Soner SEZGİN- www.elektronart.com
 * EXP: Main process for P10 LED panel driver 32x16px or 64x16px
 * Code written for MSP430G2553. Program displays 1 counter
 * on a P10 display. Counter is controlled by remote controller in NEC protocol.
 * In order to reduce code size, other protocols are disabled.
 * Remote controller receiver connected to BIT3 on port 1.
 * P10 control signals are as follows
 * P10_A		->	P2.0
 * P10_B		->	P2.1
 * P10_LATCH	->	P2.2
 * P10_OE		->	P2.3
 * P10_CLK		->	P1.5	(SPICLK)
 * P10_DATA		->	P1.7	(SPIMOSI)
 */


#include 
#include "main.h"
#include "p10.h"
#include "spi.h"
#include "serial.h"
#include "ir.h"

#define IRPIN		BIT3
#define fontsize	3

static unsigned char debug = 0;

//IR global variables
extern irparams_t irparams;
unsigned long repeated_code = 0; // Decoded value
unsigned char repeated_cnt = 0;

//Serial port global variables
static char rx;
static char	new;
static unsigned char testmode = 0;

//P10 variables
static unsigned int	counter;
static unsigned char timertick;

void main(void) {

	decode_results results;

	WDTCTL = WDTPW + WDTHOLD;		// Stop watchdog timer
	BCSCTL1 = CALBC1_8MHZ;          // Set DCO
	DCOCTL = CALDCO_8MHZ;

	P2DIR |= 0x3F;		// Set P2 low nibble as output
	P1DIR |= 0x01;		// Set P1 BIT0 as output

	uart_init();  // ~7usec @8MHz
	spi_init(); 	// ~7usec @8MHz
	IR_SetInPin(IRPIN);
	P10_Init();
	P10_Clear();
	IR_EnableIn();

	//initialize timer0 interrupt for P10 drive
	TA0CCTL0 = CCIE;                             // CCR0 interrupt enabled
	TA0CCR0 = TIMER_P10;
	TA0CTL = TASSEL_2 + MC_2;                  // SMCLK, contmode

	//initialize timer1 interrupt for IR receive
	TA1CCTL0 = CCIE;                             // CCR0 interrupt enabled
	TA1CCR0 = TIMER_IR;
	TA1CTL = TASSEL_2 + MC_1;                  // SMCLK, upmode


	__enable_interrupt();

	P10_DisplayCount(0, fontsize);

	//_BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt

	while(1){

		if(IR_Decode(&results)){
			if(results.decode_type == NEC && irparams.rawlen < 70) IR_Process(&results);
			else irparams.rawbuf[0] = 0;
		}

		if(new==1){
			new = 0;
			Serial_Process();
		}

		if(testmode==1){
			if(counter == 9999){
				P10_DisplayCount(counter, fontsize);
				msleep(500);
				P10_Clear();
				msleep(200);
				P10_DisplayCount(counter, fontsize);
				msleep(500);
				P10_Clear();
				msleep(200);
				P10_DisplayCount(counter, fontsize);
				testmode=2;
			}
			else if(counter<9988 && counter > 100) counter+=11;
			else if(counter<9993 && counter > 50) counter+=6;
			else if(counter<9999 ) counter++;
			P10_DisplayCount(counter, fontsize);
			msleep(50);
		}
		else if(testmode == 2){
			if(counter>0 && counter > 100) counter-=11;
			else if(counter>0 && counter > 50) counter-=6;
			else if(counter>0 ) counter--;
			else testmode = 0;
			P10_DisplayCount(counter, fontsize);
			msleep(50);
		}

	}
}


void IR_Process(decode_results *results){
	char asc[8];
	unsigned int i;
	unsigned long ir_value;

	ir_value = results->value;

	if( ir_value != REPEAT){
		repeated_code = results->value;
		repeated_cnt = 0;
	}
	else{
		ir_value = repeated_code;
		repeated_cnt++;
	}

	switch(ir_value){
	case IR_UP:
		if(counter<9999){
			counter++;
		}
		break;
	case IR_DOWN:
		if(counter>0){
			counter--;
		}
		break;
	case IR_OK:
		if(repeated_cnt > 5) counter = 0;
		break;
	}

	P10_DisplayCount(counter, fontsize);

	if(debug == 1){
		for(i=4; i>0; i--)	{
			h2a((char)(results->value >> ((i-1)*8)), &asc[(4-i)*2]);
		}
		uart_puts(asc);
		uart_puts("--");
		for(i=4; i>0; i--)	{
			h2a((char)(ir_value >> ((i-1)*8)), &asc[(4-i)*2]);
		}
		uart_puts(asc);
		uart_puts("\r\n");
	}

	IR_resume();

}

void Serial_Process(void){
	switch (rx){
	case '+':
		counter++;
		__disable_interrupt();
		P10_DisplayCount(counter, fontsize);
		__enable_interrupt();
		break;
	case '-':
		counter--;
		P10_DisplayCount(counter, fontsize);
		break;
	case 'c':
		counter = 0;
		break;
	case 't':
		testmode = 1;
		break;
	case '1':
		P10_SetText ("TEST");
		P10_Clear();
		ShowString(0, 2, 2, 0);
		break;
	case '2':
		P10_SetText ("KAYAN YAZI TEST    ");
		P10_Clear();
		TextToLeftScroll(2,2,9,0);
		break;
//		ShowString(0, 2, 2, 0);
	case '3':
		P10_SetText ("1234567890////");
		P10_Clear();
		TextToLeftScroll(2,3,9,0);
		break;
	default:
		uart_puts("Tanımsız tuş\r\n");
	}
	uart_putc(rx);
	new = 0;
}


// Timer A0 interrupt service routine
// Timer ISR for P10 library
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A0 (void)
{
	unsigned char p10_line;

	TA0CCR0 += TIMER_P10;

	timertick++;
	p10_line = (timertick)%4;
	write_data(p10_line);
	P2OUT &= ~OE;		//disable OE
	P2OUT &= 0xFC;
	P2OUT |= (0x3 & p10_line);
	P2OUT |= LATCH;
	usleep(10);
	P2OUT &= ~LATCH;

	P2OUT |= OE;		//Enable OE

}


//Timer ISR for IR receiver library
#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer_A1 (void)
{

	unsigned char irdata = 0;


	if(MARK){
		if(irparams.recvpin & P1IN) irdata = MARK;
		else irdata = SPACE;
	}
	else{
		if(irparams.recvpin & P1IN) irdata = SPACE;
		else irdata = MARK;
	}

	  irparams.timer++; // One more 50us tick
	  if (irparams.rawlen >= RAWBUF) {
		// Buffer overflow
		  irparams.rcvstate = STATE_STOP;
	  }
	  switch(irparams.rcvstate) {
		  case STATE_IDLE: // In the middle of a gap
			if (irdata == MARK) {
			  if (irparams.timer < GAP_TICKS) {
				// Not big enough to be a gap.
				irparams.timer = 0;
			  }
			  else {
				// gap just ended, record duration and start recording transmission
				irparams.rawlen = 0;
//				irparams.rawbuf[irparams.rawlen++] = irparams.timer;
				irparams.timer = 0;
				irparams.rcvstate = STATE_MARK;
			  }
			}
			break;
		  case STATE_MARK: // timing MARK
			  if (irdata == SPACE) {   // MARK ended, record time
			  irparams.rawbuf[irparams.rawlen++] = irparams.timer;
			  irparams.timer = 0;
			  irparams.rcvstate = STATE_SPACE;
			}
			break;
		  case STATE_SPACE: // timing SPACE
			  if (irdata == MARK) { // SPACE just ended, record it
			  irparams.rawbuf[irparams.rawlen++] = irparams.timer;
			  irparams.timer = 0;
			  irparams.rcvstate = STATE_MARK;
			}
			else { // SPACE
			  if (irparams.timer > GAP_TICKS) {
				// big SPACE, indicates gap between codes
				// Mareewqrwerk current code as ready for processing
				// Switch to STOP
				// Don't reset timer; keep counting space width
				irparams.rcvstate = STATE_STOP;
			  }
			}
			break;
		  case STATE_STOP: // waiting, measuring gap
			  if (irdata == MARK) { // reset gap timer
			  irparams.timer = 0;
			}
			break;
	  }

}

// Serial ISR
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
   rx = UCA0RXBUF;
   new = 1;
}