你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm32 NRF905 12864 SPI 8080

[复制链接]
xule 发布时间:2015-4-20 15:24
//-----------------并行 //SPI//模拟SPI//都有 #include "lcd12864.h" /****************************************/void LCD_IOinit_OUT(void)  {
0 S+ y( P0 r. V3 t' w  GPIO_InitTypeDef GPIO_InitStructure;    ) Y* V  @" M4 E, o( h- S
        RCC_APB2PeriphClockCmd(GPIO  , ENABLE);           GPIO_InitStructure.GPIO_Pin =CS|RW|CLK|PSB|RST;   
0 Y' Z! j9 K* F1 D) ]  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; % j8 \+ ?  y4 L9 p+ l" Y
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;     " ^) W( K5 \$ w* M1 ?
  GPIO_Init(LCD_IO, &GPIO_InitStructure);   
5 l  G/ N0 r$ x0 P. v}    /********»ù±¾º¯Êý*********/ void LCD_Write(uint32_t cmd,uint8_t ddata) , ~8 ?4 |+ b# A. r& s& m
{
7 T/ l* n3 x) b uint32_t temp=cmd;
  G* l8 f! d. a: ^4 B& L! u uint32_t i;
- I/ k# y) S* A6 \% o2 g RESET(CS);  
7 u, _! E5 Q, @$ h temp|=((uint32_t)(ddata&(uint8_t)0xf0)<<16)+((uint32_t)(ddata&(uint8_t)0x0f)<<12); 6 i. b/ b1 A% ]2 u' S  S% s
SET(CS); $ w& ]/ M4 Z0 N7 l1 R( `6 ?1 a9 b
for(i=0;i<24;i++) 0 U4 j6 O; W- h, o4 g
{   if(temp&0x80000000)SET(RW);    else RESET(RW);    SET(CLK);   delay_ms(1);   RESET(CLK);    temp=temp<<1; 1 g# p6 @/ Z: w" ~9 i1 |0 \$ b
}
4 n7 C5 o  D3 B2 n3 V RESET(CS);  4 S+ S: r5 f6 m
}    u32 ReaddDate ;          u8  ReaddDatebit=0;          u8 J=0; & [( {5 i& r+ @" C

2 @" {0 G4 W4 S# g2 A; b4 D" u( o8 a; @# N; s
/**************/void Display(uint8_t addr,uint8_t *Chinese) {    LCD_Write(CMD,addr);    delay_us(100);    while(*Chinese!='\0')    {     LCD_Write(DATE,*Chinese);     Chinese++;     delay_ms(1);    } }
5 l6 w7 ^  S- K' c& X0 m* v# E: w8 V' e* W7 u! [
: ~% o8 W/ C! X0 p' r" `5 `
! `  j9 I8 D2 f' v, |" n
/*******ÔÚÖ¸¶¨Î»ÖÃÏÔʾ×Ö·û´®***************/  $ I/ H8 o- g% j: p  P
void LCD_Show_String_On_Position(u8 y,u8  x, u8  *adata){ u8 address; u8 i=0; switch (y) {  case 1:address=0x80+x;break;  case 2:address=0x90+x;break;  case 3:address=0x88+x;break;  case 4:address=0x98+x;break;  default:break; } LCD_Write(CMD,address); while(*(adata+i)) {  LCD_Write(DATE,*(adata+i));        i++; }}/****************************/ void LCD_ShowNum(u8 y,u8  x,u16 num ){         u8 address;   u8 i=0;         u8  str[5];         u8 shi,ge,bai ,qian; switch (y) {  case 1:address=0x80+x;break;  case 2:address=0x90+x;break;  case 3:address=0x88+x;break;  case 4:address=0x98+x;break;  default:break; } LCD_Write(CMD,address); if(num>10000) { num=0;} else num=num;  qian=num/1000;  bai=(num-qian*1000)/100;  shi=(num-bai*100-qian*1000)/10;  ge=num%10;  str[0]=qian+'0';  str[1]=bai+'0';  str[2]=shi+'0';  str[3]='.';  str[4]=ge+'0'; if(qian==0) {           if (bai==0)        {                   if(shi==0)                 {                        for(i=2;i<5;i++)                  LCD_Write(DATE,*(str+i));                  }                                  else                           for(i=2;i<5;i++)                  LCD_Write(DATE,*(str+i));   }          if(bai!=0)        {                     for(i=1;i<5;i++)                   LCD_Write(DATE,*(str+i));         }}else   for(i=0;i<5;i++)                 LCD_Write(DATE,*(str+i));
% }  h6 U+ _+ b  \}/************³õʼ»¯LCDµÄÅäÖÃ******************/void LCD_Init(void) & p7 G+ e0 H* {; O
{            LCD_IOinit_OUT();                 RESET(CS);                  RESET(PSB);                  RESET(RST);                  delay_ms(1);                  SET(RST);                  delay_ms(1);                  LCD_Write(CMD,0x30);                  delay_ms(1);                  LCD_Write(CMD,0x0c);                  delay_ms(10);                  LCD_Write(CMD,0x01);                     delay_ms(1);      LCD_Write(CMD,0X04);                 delay_ms(1);                  LCD_Write(CMD,0x06);                       delay_ms(1);      }  //==============================================================#include "SPI_LCD.h"#include "spi.h"void SPI_LCD_Config(void){  GPIO_InitTypeDef GPIO_InitStructure;   
- A. A, }) b( T8 b! d        RCC_APB2PeriphClockCmd(GPIO,ENABLE);           GPIO_InitStructure.GPIO_Pin =CS |PSB|RST;   
* ?& l9 T9 w8 A) D2 @4 p, K  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; : m$ i4 K' O; V" o
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;     
3 r+ ?5 u# \- y/ T0 ~  GPIO_Init(LCD_IO, &GPIO_InitStructure);                    SPI2_Init();' ^* ~( D+ q6 R# @' [- ~' B# T: {
}4 ]- t1 k" ?# T6 V7 R
void LCD_Write(uint8_t cmd,uint8_t ddata) {  RESET(CS);   SET(CS);  SPI2_WriteByte(cmd); SPI2_WriteByte(ddata&0xf0); SPI2_WriteByte((ddata&0x0f)<<4); RESET(CS);  } : [! X* }; N( I  S. y: I* U
  
% j' E/ J: _7 y  c( P' Vvoid LCD_Show_String_On_Position(u8 y,u8  x, u8  *adata){ u8 address; u8 i=0; switch (y) {  case 1:address=0x80+x;break;  case 2:address=0x90+x;break;  case 3:address=0x88+x;break;  case 4:address=0x98+x;break;  default:break; } LCD_Write(CMD,address); while(*(adata+i)) {  LCD_Write(DATE,*(adata+i));        i++; } } void SPI_LCD_Init(void)
3 j5 Y- X5 h/ x9 r. v! s2 H) K8 b{            SPI_LCD_Config();                 RESET(CS);                  RESET(PSB);                  RESET(RST);                  delay_ms(1);                  SET(RST);                  delay_ms(1);                  LCD_Write(CMD,0x30);                  delay_ms(1);                  LCD_Write(CMD,0x0c);                  delay_ms(10);                  LCD_Write(CMD,0x01);                     delay_ms(1);      LCD_Write(CMD,0X04);                 delay_ms(1);                  LCD_Write(CMD,0x06);                       delay_ms(1);      }  $ T7 |% V+ [: N2 M- Q9 M
/ f2 I3 i7 \& \/ P
赞 收藏 评论6 发布时间:2015-4-20 15:24

举报

6个回答
1407W 回答时间:2015-5-6 16:20:21
此帖仅作者可见
拼命三郎 回答时间:2015-4-21 10:01:07
此帖仅作者可见
拼命三郎 回答时间:2015-4-21 10:00:52
此帖仅作者可见
wamcncn 回答时间:2015-4-20 21:26:45
此帖仅作者可见
wyxy163@126.com 回答时间:2015-4-20 15:43:58
提示: 作者被禁止或删除 内容自动屏蔽
xule 回答时间:2015-4-20 15:25:41
此帖仅作者可见
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版