removing old files as eclipse builds now

Added #define organisation over mfg logo (no actual build effect though just for neatness)
Creating a CubeMX project to match settings for future use
More comments and cleaning up
This commit is contained in:
Ben V. Brown
2016-09-11 21:54:52 +10:00
parent 871e8e35c9
commit 0b4068976c
153 changed files with 2549 additions and 79493 deletions

View File

@@ -50,7 +50,7 @@ void USB_Port(u8 state);
void NVIC_Config(u16 tab_offset);
void RCC_Config(void);
void GPIO_Config(void);
void Ad_Init(void);
void Adc_Init(void);
void Init_Timer2(void);
void Init_Timer3(void);
void TIM2_ISR(void);

View File

@@ -21,6 +21,8 @@
#define G6_TIMER gTime[5]/*SWITCH_SHOW_TIMER*/
#define UI_TIMER gTime[6]/*UI_TIMER ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>*/
#define KD_TIMER gTime[7]/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ*/
///^^-- All the times in gTime are decremented by 1 if >0 by timer2 tick <bottom of bios.c>
//------------------------------ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------//
#define KEY_ST(KEY_PIN) GPIO_ReadInputDataBit(GPIOA, KEY_PIN)
#define NO_KEY 0x0 /*NO Keys pressed*/

View File

@@ -1,6 +1,7 @@
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
Brief : <20>ײ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Author : bure
*******************************************************************************/
Modified by Ben V. Brown into English
*******************************************************************************/
#include "stm32f10x.h"
#define PRODUCT_INFO "TS100"
@@ -14,7 +15,7 @@
#define SPIx SPI1
#define FLASH_PAGE 0x0400
//--------------------------- key <EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> ------------------------------//
//--------------------------- key Definitions ------------------------------//
#define KEY1_PIN GPIO_Pin_9 //PA8
#define KEY2_PIN GPIO_Pin_6 //PA6
#define KEY_1 !(GPIOA->IDR & KEY1_PIN)
@@ -31,7 +32,6 @@
#define I2C1_DR_Address 0x40005410
#define I2C2_DR_Address 0x40005810
#define SERIAL_NO1 (*(u32*)0x1FFFF7E8)
#define SERIAL_NO2 (*(u32*)0x1FFFF7EC)
#define SERIAL_NO3 (*(u32*)0x1FFFF7F0)
@@ -53,16 +53,15 @@
#define INT1_PIN GPIO_Pin_5 //PB5
#define INT2_PIN GPIO_Pin_3 //PB3
//------------------------------ GPIO <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD> -------------------------------//
#define GPIOA_OUTPUT() GPIOA->ODR = 0xFFFF;
#define GPIOA_L_DEF() GPIOA->CRL = 0x08888888; /* Ai7 K2 xxx xxx xxx xxx xxx xxx */
#define GPIOA_H_DEF() GPIOA->CRH = 0x8BBBB883; /* xxx SWC SWD D+ D- xxx K1 nCR */
#define GPIOB_OUTPUT() GPIOB->ODR = 0xFFFF;
#define GPIOB_L_DEF() GPIOB->CRL = 0x44838800; /* SDA SCL It1 Po It2 xxx Ai9 Ai8 */
#define GPIOB_H_DEF() GPIOB->CRH = 0x88888888; /* xxx xxx xxx xxx xxx xxx xxx xxx */
//--------------------------------- RCC <20><><EFBFBD><EFBFBD> ---------------------------------//
#define RCC_PLL_EN() RCC->CR |= 0x01000000;// PLL En

View File

@@ -1,237 +1,283 @@
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
File Name : 2FAT12.c
Version : S100 APP Ver 2.11
Description:
Author : bure & Celery
Data: 2015/08/03
History:
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
File Name : 2FAT12.c
Version : S100 APP Ver 2.11
Description:
Author : bure & Celery
Data: 2015/08/03
History:
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
#include <string.h>
#include "FAT12.h"
#include "Bios.h"
#define FAT_LEN 0x1800
#define FAT1_BASE 0x00001000 // FAT1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
#define FAT2_BASE 0x00002800 // FAT2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
#define ROOT_BASE 0x00004000 // <20><>Ŀ¼<C4BF><C2BC>ʼ<EFBFBD><CABC>ַ
#define FILE_BASE 0x00008000 // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
#define SEC_LEN 0x200 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define FAT1_SEC 0x0C // FAT1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define FAT2_SEC 0x0C // FAT2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define FAT1_BASE 0x00001000 // FAT1
#define FAT2_BASE 0x00002800 // FAT2
#define ROOT_BASE 0x00004000 //
#define FILE_BASE 0x00008000 //
#define SEC_LEN 0x200 //
#define FAT1_SEC 0x0C // FAT1
#define FAT2_SEC 0x0C // FAT2
#define OK 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SEC_ERR 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
#define FAT_ERR 2 // FAT<41><54><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
#define OVER 3 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define NEW 4 // <20><>Ŀ¼<C4BF><C2BC>
#define END 0xFFF // <20><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
#define OW 0 // <20><>д(<28><><EFBFBD>ݴ<EFBFBD>0<EFBFBD><30>1<EFBFBD><31>д)
#define RW 1 // <20><>д
#define OK 0 //
#define SEC_ERR 1 //
#define FAT_ERR 2 //
#define OVER 3 //
#define NEW 4 //
#define END 0xFFF //
#define OW 0 //
#define RW 1 //
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵغź󷵻<EFBFBD>
*******************************************************************************/
u8 NextCluster(u16* pCluster)
{
u16 FatNum;
u32 Addr = FAT1_BASE +(*pCluster + *pCluster/2);
Function:
Description:
Input:
*******************************************************************************/
u8 NextCluster(u16* pCluster) {
u16 FatNum;
u32 Addr = FAT1_BASE + (*pCluster + *pCluster / 2);
*(pCluster+1)= *pCluster; // <20><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
*(pCluster + 1) = *pCluster; // <20><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
// *(pCluster+1)= 0;
if((*pCluster >= END)||(*pCluster < 2)) return OK;
if(ReadDiskData((u8*)&FatNum, Addr, 2)!= OK) return SEC_ERR;
*pCluster = (*pCluster & 1)?(FatNum >>4):(FatNum & 0x0FFF); // ָ<><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
if ((*pCluster >= END) || (*pCluster < 2))
return OK;
if (ReadDiskData((u8*) &FatNum, Addr, 2) != OK)
return SEC_ERR;
*pCluster = (*pCluster & 1) ? (FatNum >> 4) : (FatNum & 0x0FFF); // ָ<><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(512 Bytes), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
*******************************************************************************/
u8 ReadFileSec(u8* pBuffer, u16* pCluster)
{
u32 ReadAddr = FILE_BASE + SEC_LEN*(*pCluster-2);
Function:
Description:
Input:
*******************************************************************************/
u8 ReadFileSec(u8* pBuffer, u16* pCluster) {
u32 ReadAddr = FILE_BASE + SEC_LEN * (*pCluster - 2);
if(ReadDiskData(pBuffer, ReadAddr, 256)!=OK) return SEC_ERR; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pBuffer += 256;
ReadAddr += 256;
if(ReadDiskData(pBuffer, ReadAddr, 256)!=OK) return SEC_ERR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(NextCluster(pCluster)!=0) return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
if (ReadDiskData(pBuffer, ReadAddr, 256) != OK)
return SEC_ERR; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pBuffer += 256;
ReadAddr += 256;
if (ReadDiskData(pBuffer, ReadAddr, 256) != OK)
return SEC_ERR; // Failed to read the sector
if (NextCluster(pCluster) != 0)
return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
/*******************************************************************************
д<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(512 Bytes)<29><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ǰFAT<41><54><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
*******************************************************************************/
u8 ProgFileSec(u8* pBuffer, u16* pCluster)
{
u16 Tmp;
u32 ProgAddr = FILE_BASE + SEC_LEN*(*pCluster-2);
Function:
Description:
Input:
*******************************************************************************/
u8 ProgFileSec(u8* pBuffer, u16* pCluster) {
u16 Tmp;
u32 ProgAddr = FILE_BASE + SEC_LEN * (*pCluster - 2);
if(ProgDiskPage(pBuffer, ProgAddr)!= OK) return SEC_ERR; // дǰ<D0B4><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pBuffer += 256;
ProgAddr += 256;
if(ProgDiskPage(pBuffer, ProgAddr)!= OK) return SEC_ERR; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Tmp = *pCluster;
switch(Tmp) {
case 0: // <20><><EFBFBD>дغ<D0B4>
case 1: // <20><><EFBFBD>дغ<D0B4>
if(SeekBlank (pBuffer, pCluster )!= OK) return OVER;
if(SetCluster(pBuffer, pCluster )!= OK) return SEC_ERR;
*(pCluster+1) = Tmp;
return OK;
case END: // <20><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
default :
if(NextCluster(pCluster)!= OK) return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
if (ProgDiskPage(pBuffer, ProgAddr) != OK)
return SEC_ERR; // дǰ<D0B4><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pBuffer += 256;
ProgAddr += 256;
if (ProgDiskPage(pBuffer, ProgAddr) != OK)
return SEC_ERR; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Tmp = *pCluster;
switch (Tmp) {
case 0: // <20><><EFBFBD>дغ<D0B4>
case 1: // <20><><EFBFBD>дغ<D0B4>
if (SeekBlank(pBuffer, pCluster) != OK)
return OVER;
if (SetCluster(pBuffer, pCluster) != OK)
return SEC_ERR;
*(pCluster + 1) = Tmp;
return OK;
case END: // <20><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
default:
if (NextCluster(pCluster) != OK)
return FAT_ERR; // ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><EFBFBD>дغţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>дغż<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дغ<EFBFBD>
*******************************************************************************/
u8 SeekBlank(u8* pBuffer, u16* pCluster)
{
u16 Offset, Tmp, i, n = 0;
u32 SecAddr;
Function:
Description:
Input:
*******************************************************************************/
u8 SeekBlank(u8* pBuffer, u16* pCluster) {
u16 Offset, Tmp, i, n = 0;
u32 SecAddr;
for(i=0; i<4096; i++) {
Offset = i + i/2;
if((Offset%256)== 0) {
SecAddr = FAT1_BASE +(Offset &(~0xFF));
if(ReadDiskData(pBuffer, SecAddr, 258)!= 0) return SEC_ERR;
}
Offset %= 256;
Tmp = pBuffer[Offset] + (pBuffer[Offset+1] <<8);
Tmp = (i & 1)?(Tmp >>4):(Tmp & 0xFFF);
if(Tmp == 0) {
*pCluster++ = i;
n++;
if(n > 1) return OK;
}
}
*(pCluster+1)= 0xFFF;
return OK;
for (i = 0; i < 4096; i++) {
Offset = i + i / 2;
if ((Offset % 256) == 0) {
SecAddr = FAT1_BASE + (Offset & (~0xFF));
if (ReadDiskData(pBuffer, SecAddr, 258) != 0)
return SEC_ERR;
}
Offset %= 256;
Tmp = pBuffer[Offset] + (pBuffer[Offset + 1] << 8);
Tmp = (i & 1) ? (Tmp >> 4) : (Tmp & 0xFFF);
if (Tmp == 0) {
*pCluster++ = i;
n++;
if (n > 1)
return OK;
}
}
*(pCluster + 1) = 0xFFF;
return OK;
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD>д<EFBFBD><EFBFBD>FAT<EFBFBD><EFBFBD>ǰ<EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ǰ<EFBFBD>غ<EFBFBD>Ϊԭ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD>
*******************************************************************************/
u8 SetCluster(u8* pBuffer, u16* pCluster)
{
u16 Offset, Tmp, i, k;
u32 SecAddr;
Function:
Description:
Input:
*******************************************************************************/
u8 SetCluster(u8* pBuffer, u16* pCluster) {
u16 Offset, Tmp, i, k;
u32 SecAddr;
i = *pCluster; // <20><>ȡԭ<C8A1><D4AD>ǰ<EFBFBD>غ<EFBFBD>
k = *(pCluster+1); // <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD>غ<EFBFBD>
*pCluster = k;
Offset = i + i/2;
SecAddr = FAT1_BASE +(Offset &(~0xFF));
Tmp = Offset & 0xFF;
if(ReadDiskData(pBuffer, SecAddr, 256)!= 0) return SEC_ERR;
if(i & 1) pBuffer[Tmp]=((k<<4)& 0xF0)+(pBuffer[Tmp]& 0x0F);
else pBuffer[Tmp]= k;
if(Tmp++ < 256) {
if(i & 1) pBuffer[Tmp]= k>>4;
else pBuffer[Tmp]=((k>>8)& 0x0F)+(pBuffer[Tmp]& 0xF0);
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
} else {
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
SecAddr += 256;
if(ReadDiskData(pBuffer, SecAddr, 256)!= 0) return SEC_ERR;
if(i & 1) pBuffer[0]= k>>4;
else pBuffer[0]=((k>>8)& 0x0F)+(pBuffer[0]& 0xF0);
if(ProgDiskPage(pBuffer, SecAddr)!= 0) return SEC_ERR;
}
return OK;
i = *pCluster; // <20><>ȡԭ<C8A1><D4AD>ǰ<EFBFBD>غ<EFBFBD>
k = *(pCluster + 1); // <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD>غ<EFBFBD>
*pCluster = k;
Offset = i + i / 2;
SecAddr = FAT1_BASE + (Offset & (~0xFF));
Tmp = Offset & 0xFF;
if (ReadDiskData(pBuffer, SecAddr, 256) != 0)
return SEC_ERR;
if (i & 1)
pBuffer[Tmp] = ((k << 4) & 0xF0) + (pBuffer[Tmp] & 0x0F);
else
pBuffer[Tmp] = k;
if (Tmp++ < 256) {
if (i & 1)
pBuffer[Tmp] = k >> 4;
else
pBuffer[Tmp] = ((k >> 8) & 0x0F) + (pBuffer[Tmp] & 0xF0);
if (ProgDiskPage(pBuffer, SecAddr) != 0)
return SEC_ERR;
} else {
if (ProgDiskPage(pBuffer, SecAddr) != 0)
return SEC_ERR;
SecAddr += 256;
if (ReadDiskData(pBuffer, SecAddr, 256) != 0)
return SEC_ERR;
if (i & 1)
pBuffer[0] = k >> 4;
else
pBuffer[0] = ((k >> 8) & 0x0F) + (pBuffer[0] & 0xF0);
if (ProgDiskPage(pBuffer, SecAddr) != 0)
return SEC_ERR;
}
return OK;
}
/*******************************************************************************
Function:
Description:
Input:
*******************************************************************************/
u8 FAT_SearchFile(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr,
u32* flag) {
u16 i, n;
*******************************************************************************/
u8 FAT_SearchFile(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr,u32* flag)
{
u16 i, n;
*pCluster = 0;
for(*pDirAddr=ROOT_BASE; *pDirAddr<FILE_BASE; ) {
if(ReadDiskData(pBuffer, *pDirAddr, 256)!= OK) return SEC_ERR;
for(n=0; n<256; n+=32) {
for(i=0; i<4; i++) {
if(pBuffer[n + i]!= 0) {
if(pBuffer[n + i]!= pFileName[i]) break;
if(i == 3) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
*pCluster = *(u16*)(pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
} else return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>󷵻<EFBFBD>
}
*pDirAddr += 32;
}
}
return OVER;
*pCluster = 0;
for (*pDirAddr = ROOT_BASE; *pDirAddr < FILE_BASE;) {
if (ReadDiskData(pBuffer, *pDirAddr, 256) != OK)
return SEC_ERR;
for (n = 0; n < 256; n += 32) {
for (i = 0; i < 4; i++) {
if (pBuffer[n + i] != 0) {
if (pBuffer[n + i] != pFileName[i])
break;
if (i == 3) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
*pCluster = *(u16*) (pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
} else
return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>󷵻<EFBFBD>
}
*pDirAddr += 32;
}
}
return OVER;
}
/*******************************************************************************
<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>غż<EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD> 0<>غż<D8BA><C5BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD>ַ
*******************************************************************************/
u8 OpenFileRd(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr)
{
u16 i, n;
Function:OpenFileRd
Description: Opens a file for reading from
Input:
*******************************************************************************/
u8 OpenFileRd(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr) {
u16 i, n;
*pCluster = 0;
for(*pDirAddr=ROOT_BASE; *pDirAddr<FILE_BASE; ) {
if(ReadDiskData(pBuffer, *pDirAddr, 256)!= OK) return SEC_ERR;
for(n=0; n<256; n+=32) {
for(i=0; i<11; i++) {
if(pBuffer[n + i]!= 0) {
if(pBuffer[n + i]!= pFileName[i]) break;
if(i == 10) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
*pCluster = *(u16*)(pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
} else return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>󷵻<EFBFBD>
}
*pDirAddr += 32;
}
}
return OVER;
*pCluster = 0;
for (*pDirAddr = ROOT_BASE; *pDirAddr < FILE_BASE;) {
if (ReadDiskData(pBuffer, *pDirAddr, 256) != OK)
return SEC_ERR;
for (n = 0; n < 256; n += 32) {
for (i = 0; i < 11; i++) {
if (pBuffer[n + i] != 0) {
if (pBuffer[n + i] != pFileName[i])
break;
if (i == 10) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
*pCluster = *(u16*) (pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
return OK;
}
} else
return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>󷵻<EFBFBD>
}
*pDirAddr += 32;
}
}
return OVER;
}
/*******************************************************************************
дģʽ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>غż<EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD>ַ
*******************************************************************************/
u8 OpenFileWr(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr)
{
u16 i, n;
Function: OpenFileWr
Description: Opens a file for writing to
Input:
*******************************************************************************/
u8 OpenFileWr(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr) {
u16 i, n;
i = OpenFileRd(pBuffer, pFileName, pCluster, pDirAddr);
if(i != NEW) return i;
else { // <20><>ǰ<EFBFBD><C7B0>Ϊ<EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>
if(SeekBlank(pBuffer, pCluster)!= OK) return OVER; // <20><>FAT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
n =*pDirAddr & 0xFF; // nΪ<6E><CEAA>ǰҳĿ¼<C4BF><C2BC>
if(ReadDiskData(pBuffer,(*pDirAddr)-n, 256)!= OK) return SEC_ERR;
for(i=0; i<11; i++) pBuffer[n + i]= pFileName[i]; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD>
*(u16*)(pBuffer + n + 0x1A)= *pCluster;
if(ProgDiskPage(pBuffer,(*pDirAddr)-n)!= OK) return SEC_ERR;
return OK;
}
i = OpenFileRd(pBuffer, pFileName, pCluster, pDirAddr);
if (i != NEW)
return i;
else { // <20><>ǰ<EFBFBD><EFBFBD>Ϊ<EFBFBD>հ<EFBFBD>Ŀ¼<EFBFBD><EFBFBD>
if (SeekBlank(pBuffer, pCluster) != OK)
return OVER; // <20><>FAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
n = *pDirAddr & 0xFF; // <EFBFBD><EFBFBD>ǰҳĿ¼<EFBFBD><EFBFBD>
if (ReadDiskData(pBuffer, (*pDirAddr) - n, 256) != OK)
return SEC_ERR;
for (i = 0; i < 11; i++)
pBuffer[n + i] = pFileName[i]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>
*(u16*) (pBuffer + n + 0x1A) = *pCluster;
if (ProgDiskPage(pBuffer, (*pDirAddr) - n) != OK)
return SEC_ERR;
return OK;
}
}
/*******************************************************************************
<EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>FAT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FAT1<EFBFBD><EFBFBD>FAT2
*******************************************************************************/
u8 CloseFile(u8* pBuffer, u32 Lenght, u16* pCluster, u32* pDirAddr)
{
u16 n;
Function: CloseFile
Description: Closes a file that was previously opened
Input:
*******************************************************************************/
u8 CloseFile(u8* pBuffer, u32 Lenght, u16* pCluster, u32* pDirAddr) {
u16 n;
// *pCluster = *(pCluster+1); // <20><>ȡǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
*(pCluster+1) = 0xFFF;
SetCluster(pBuffer, pCluster);
if(ReadDiskData(pBuffer, (*pDirAddr &(~0xFF)), 256)!= OK) return SEC_ERR;
*(u8* )(pBuffer +(*pDirAddr & 0xFF)+ 0x0B)= 0x20;
*(u32*)(pBuffer +(*pDirAddr & 0xFF)+ 0x1C)= Lenght;
if(ProgDiskPage(pBuffer, (*pDirAddr &(~0xFF)))!= OK) return SEC_ERR;
for(n=0; n<FAT1_SEC; n++) {
if(ReadDiskData(pBuffer, FAT1_BASE+n*256, 256)!= OK) return SEC_ERR;
if(ProgDiskPage(pBuffer, FAT2_BASE+n*256 )!= OK) return SEC_ERR;
}
return OK;
*(pCluster + 1) = 0xFFF;
SetCluster(pBuffer, pCluster);
if (ReadDiskData(pBuffer, (*pDirAddr & (~0xFF)), 256) != OK)
return SEC_ERR;
*(u8*) (pBuffer + (*pDirAddr & 0xFF) + 0x0B) = 0x20;
*(u32*) (pBuffer + (*pDirAddr & 0xFF) + 0x1C) = Lenght;
if (ProgDiskPage(pBuffer, (*pDirAddr & (~0xFF))) != OK)
return SEC_ERR;
for (n = 0; n < FAT1_SEC; n++) {
if (ReadDiskData(pBuffer, FAT1_BASE + n * 256, 256) != OK)
return SEC_ERR;
if (ProgDiskPage(pBuffer, FAT2_BASE + n * 256) != OK)
return SEC_ERR;
}
return OK;
}
/******************************** END OF FILE *********************************/

View File

@@ -18,9 +18,9 @@
/******************************************************************************/
#define ADC1_DR_Address ((u32)0x4001244C)
vu8 gSk = 0; //
vu32 gTimeOut, gMs_timeout;
volatile u32 gTime[8];
volatile u32 gTime[8]; //times for timer storage
//^-- gTime is automatically decremented on each firing of timer 2 if >0
vu16 ADC1ConvertedValue[2];
vu32 gHeat_cnt = 0;
@@ -105,10 +105,8 @@ void USB_Port(u8 state) {
}
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RCC_Config
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ӳ<EFBFBD>ʼ<EFBFBD><CABC>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
Function:RCC_Config
Description:Setup the system clocks to use internal HSE to run the system at 48Mhz
*******************************************************************************/
void RCC_Config(void) {
RCC_DeInit();
@@ -138,10 +136,9 @@ void RCC_Config(void) {
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); // USBCLK = 48MHz
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: NVIC_Config
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A>жϳ<D0B6>ʼ<EFBFBD><CABC>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:tab_offset
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
Function: NVIC_Config
Description: Configures the NVIC table in the hardware
Input: (tab_offset) the table offset for the NVIC
*******************************************************************************/
void NVIC_Config(u16 tab_offset) {
NVIC_InitTypeDef NVIC_InitStructure;
@@ -155,10 +152,8 @@ void NVIC_Config(u16 tab_offset) {
NVIC_Init(&NVIC_InitStructure);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GPIO_Config
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>GPIO
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
Function:GPIO_Config
Description: Configures all the GPIO into required states
*******************************************************************************/
void GPIO_Config(void) {
GPIO_InitTypeDef GPIO_InitStructure;
@@ -177,7 +172,7 @@ void GPIO_Config(void) {
GPIOB_H_DEF()
;
//------ PA7<EFBFBD><EFBFBD>Ϊģ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>Ai7<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ----------------------------------------//
//------ PA7 TMP36 Analog input ----------------------------------------//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
@@ -188,15 +183,15 @@ void GPIO_Config(void) {
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//------- <EFBFBD><EFBFBD><EFBFBD>ȿ<EFBFBD><EFBFBD><EFBFBD>λ PB4--------------------------------------------------------//
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); // PB4=JNTRST
//------- Heat_Pin - Iron enable output PB4--------------------------------------------------------//
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); //Disable PB4=JNTRST
GPIO_InitStructure.GPIO_Pin = HEAT_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//------ PB0<EFBFBD><EFBFBD>Ϊģ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>Ai8<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---------------------------------------//
//------ PB0 Iron temp input---------------------------------------//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
@@ -206,18 +201,16 @@ void GPIO_Config(void) {
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//-------- K1 = PA8, K2 = PA6 ----------------------------------------------------------//
//-------- K1 = PA9, K2 = PA6 ----------------------------------------------------------//
GPIO_InitStructure.GPIO_Pin = KEY1_PIN | KEY2_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Ad_Init
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ<EFBFBD><CABC> AD
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
Function: Adc_Init
Description:Enable the ADC's and setup the DMA as well to automatically read them to system ram.
*******************************************************************************/
void Ad_Init(void) {
void Adc_Init(void) {
u32 timeout = 10 * 0x1000;
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
@@ -340,20 +333,20 @@ void Init_Timer3(void) {
NVIC_Init(&NVIC_InitStructure);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: TIM2_ISR
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʱ<EFBFBD><CAB1>2<EFBFBD>жϺ<D0B6><CFBA><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
Function:TIM2_ISR
Description:Handles Timer 2 tick.
Automatically decrements all >0 values in gTime.
Also reads the buttons every 4 ticks
*******************************************************************************/
void TIM2_ISR(void) {
u8 i;
static u8 buttonReadDivider;
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); // Clear interrupt flag
for (i = 0; i < 8; i++)
for (u8 i = 0; i < 8; i++)
if (gTime[i] > 0)
gTime[i]--;
if (++gSk % 4 == 0)
if (++buttonReadDivider % 4 == 0)
Scan_Key();
}
/*******************************************************************************
@@ -362,7 +355,7 @@ void TIM2_ISR(void) {
If the Heat_cnt >0 then heater on, otherwise off.
*******************************************************************************/
void TIM3_ISR(void) {
static u8 heat_flag = 0;
volatile static u8 heat_flag = 0;
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); // Clear interrupt flag

View File

@@ -41,8 +41,8 @@ const DEVICE_INFO_SYS info_def = { "2.12", //Ver
struct _pid {
s16 settemp; //Current ideal setpoint for the temp
s16 actualtemp; //Actual current temp of the tip
s16 err; //
s16 err_last; //
s16 err; //Error term
s16 err_last; //last error term
s32 ht_time; //
u16 kp, ki, kd; //Constants for the PID Controller
s32 integral; //
@@ -125,7 +125,7 @@ void Pid_Init(void) {
/*******************************************************************************
Function:Pid_Realize
Description:
Description: Calculates the next heating value using the PID algorithum
Input:Current temp from the tip
Output:
*******************************************************************************/
@@ -393,7 +393,7 @@ void Status_Tran(void) //
back_prestatus = 1;
break;
case KEY_CN|KEY_V3:
Zero_Calibration();
Zero_Calibration(); //Calibrate the temperature (i think??)
if(Get_CalFlag() == 1) {
Disk_BuffInit();
Config_Analysis(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>
@@ -403,20 +403,20 @@ void Status_Tran(void) //
default:
break;
}
if(back_prestatus == 1) {
back_prestatus = 0;
Set_HeatingTime(0);
Set_CtrlStatus(IDLE);
gPre_status = THERMOMETER;
gIs_restartkey = 1;
Set_LongKeyFlag(0);
KD_TIMER = 50; //
if(back_prestatus == 1) { //we are exiting
back_prestatus = 0;//clear flag
Set_HeatingTime(0);//turn off heater? (not sure why this is done again)
Set_CtrlStatus(IDLE);//Goto IDLE state
gPre_status = THERMOMETER;//set previous state
gIs_restartkey = 1;//signal soft restart required as we may have done a calibration
Set_LongKeyFlag(0);//reset long key hold flag
KD_TIMER = 50;//
}
break;
case ALARM:
case ALARM: //An error has occured so we are in alarm state
switch(Get_AlarmType()) {
case HIGH_TEMP:
case SEN_ERR:
case HIGH_TEMP: //over temp condition
case SEN_ERR://sensor reading error
wk_temp = device_info.t_work;
gTemp_data = Get_Temp(wk_temp);
if(Get_AlarmType() == NORMAL_TEMP) {
@@ -424,20 +424,20 @@ void Status_Tran(void) //
Set_UpdataFlag(0);
}
break;
case HIGH_VOLTAGE:
case LOW_VOLTAGE:
case HIGH_VOLTAGE: //over voltage
case LOW_VOLTAGE://under voltage
if(Read_Vb(1) >= 1 && Read_Vb(1) <= 3) {
Set_HeatingTime(0);
Set_LongKeyFlag(0);
Set_HeatingTime(0); //turn off heater
Set_LongKeyFlag(0);//reset key flag
gIs_restartkey = 1;
UI_TIMER = 2; // 2<><32>
UI_TIMER = 2;// 2<><32>
gPre_status = THERMOMETER;
Set_CtrlStatus(IDLE);
}
break;
}
if(Get_HeatingTime() != 0) {
//V-- No idea what this does yet.. At all.. since it will always be skipped..
if(Get_HeatingTime != 0) {
Set_HeatingTime(0); //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
HEAT_OFF();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,13 @@
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
File Name : main.c
Version : S100 APP Ver 2.11
Description:
Author : Celery
Data: 2015/07/07
History:
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
File Name : main.c
Version : S100 APP Ver 2.11
Description:
Author : Celery
Data: 2015/07/07
History:
2016/8/11 Updates by Ben V. Brown <ralim@ralimtek.com> - Cleanup and english comments
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
#include <string.h>
#include <stdio.h>
#include "APP_Version.h"
@@ -20,50 +21,42 @@ History:
#include "Oled.h"
#include "CTRL.h"
#include "Hardware.h"
int main(void) {
RCC_Config(); //setup system clock
NVIC_Config(0x4000);
Init_Timer2(); //init the timer
Init_Timer3();
GPIO_Config();
USB_Port(DISABLE);
Delay_Ms(200);
USB_Port(ENABLE);
USB_Init();
I2C_Configuration(); //init the i2c bus
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: main
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ѭ<EFBFBD><D1AD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
int main(void)
{
RCC_Config();
NVIC_Config(0x4000);
Init_Timer2();
Init_Timer3();
GPIO_Config();
USB_Port(DISABLE);
Delay_Ms(200);
USB_Port(ENABLE);
USB_Init();
I2C_Configuration();
Ad_Init();
if (Get_CtrlStatus() != CONFIG) StartUp_Accelerated();
System_Init();
Init_Oled();
Clear_Screen();
Init_Gtime();
APP_Init();
Disk_BuffInit();
Config_Analysis(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>
Pid_Init();
Set_gKey(NO_KEY);
Start_Watchdog(3000);
while (1) {
Clear_Watchdog();
if (Get_CtrlStatus() != CONFIG && LEAVE_WAIT_TIMER == 0) {
Check_Accelerated();
LEAVE_WAIT_TIMER = 50;
}
OLed_Display(); //<2F><>ʾCtrl_status
Status_Tran(); //<2F><><EFBFBD>ݵ<EFBFBD>ǰ״̬<D7B4><CCAC><EFBFBD><EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ת<EFBFBD><D7AA>
}
Adc_Init(); //init adc and dma
if (Get_CtrlStatus() != CONFIG)
StartUp_Accelerated();
System_Init();
Init_Oled();
Clear_Screen();
Init_Gtime();
APP_Init();
Disk_BuffInit();
Config_Analysis(); //read in config from virtual disk
Pid_Init(); //init the pid to starting values
Set_gKey(NO_KEY); //reset keys
Start_Watchdog(3000);
while (1) {
Clear_Watchdog(); //reset the Watchdog
if (Get_CtrlStatus() != CONFIG && LEAVE_WAIT_TIMER== 0) {
Check_Accelerated(); //update readings from the accelerometer
LEAVE_WAIT_TIMER = 50;
}
OLed_Display(); //Draw in the Oled display
Status_Tran(); //Handle user input and mode changing
}
}
/******************************** END OF FILE *********************************/

View File

@@ -1,12 +1,12 @@
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
File Name : Oled.c
Version : S100 APP Ver 2.11
Description:
Author : Celery
Data: 2015/07/07
History:
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
File Name : Oled.c
Version : S100 APP Ver 2.11
Description:
Author : Celery
Data: 2015/07/07
History:
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*******************************************************************************/
#include <stdio.h>
#include <string.h>
@@ -18,301 +18,298 @@ History:
#include "Disk.h"
#include "UI.h"
const u8 Mini[] = {/*12*16*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,
0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,0xFE,0xFC,0x78,
0x30,0x80,0xC0,0xC0,0x00,0x18,0x9C,0xCE,0xE6,0xF0,0xF8,0xFC,0xFE,0xFE,0xFC,0xF8,
0xF0,0xE0,0xC0,0xE0,0xF0,0xF8,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x0F,0x07,0x03,0x01,0x03,0x07,0x0F,0x1F,
0x3F,0x7F,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x03,0x07,0x07,0x03,0x19,0x1C,0x0E,
0x67,0x73,0x39,0x1C,0x0E,0x07,0x03,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0x7F,0x3F,
0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.BMP.bmp",0*/
//Choose startup logo by manufacturer
#ifdef MFTSEEED
//V -- Seeed startup logo
const u8 Seeed[] = {/*12*16*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0,
0x80, 0x00, 0x00, 0xC0, 0xF8, 0x38, 0x04, 0x00, 0x04, 0x38, 0xF8, 0xC0,
0x00, 0x00, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x30,
0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30,
0x10, 0x10, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x80, 0xC0, 0x60,
0x30, 0x10, 0x10, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x60,
0x30, 0x10, 0x10, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x80, 0xC0,
0x40, 0x20, 0x20, 0x20, 0x20, 0x40, 0xC0, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x0F, 0x1C, 0x38, 0x23, 0x6F, 0x5C, 0x00, 0x00, 0x00, 0x5C, 0x6F, 0x23,
0x38, 0x1C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x23,
0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x07, 0x1E, 0x32, 0x22,
0x42, 0x42, 0x42, 0x42, 0x62, 0x32, 0x03, 0x00, 0x00, 0x07, 0x1E, 0x32,
0x22, 0x42, 0x42, 0x42, 0x42, 0x22, 0x32, 0x03, 0x00, 0x07, 0x1E, 0x32,
0x22, 0x42, 0x42, 0x42, 0x42, 0x62, 0x32, 0x03, 0x00, 0x00, 0x0F, 0x18,
0x10, 0x20, 0x20, 0x20, 0x20, 0x10, 0x18, 0x7F, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, /*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.ddMP.bmp",0*/
};
const u8 Seeed[] = {/*12*16*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0x00,0x00,0xC0,0xF8,0x38,0x04,0x00,
0x04,0x38,0xF8,0xC0,0x00,0x00,0x80,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x30,
0x10,0x10,0x10,0x10,0x10,0x20,0x00,0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,
0x60,0xC0,0x80,0x00,0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,0x60,0xC0,0x80,
0x00,0x80,0xC0,0x60,0x30,0x10,0x10,0x10,0x30,0x60,0xC0,0x80,0x00,0x00,0x80,0xC0,
0x40,0x20,0x20,0x20,0x20,0x40,0xC0,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0F,0x1C,0x38,0x23,0x6F,0x5C,0x00,0x00,
0x00,0x5C,0x6F,0x23,0x38,0x1C,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x23,
0x42,0x42,0x42,0x42,0x42,0x22,0x1C,0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,
0x62,0x32,0x03,0x00,0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,0x22,0x32,0x03,
0x00,0x07,0x1E,0x32,0x22,0x42,0x42,0x42,0x42,0x62,0x32,0x03,0x00,0x00,0x0F,0x18,
0x10,0x20,0x20,0x20,0x20,0x10,0x18,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.ddMP.bmp",0*/
};
#ifdef SSD1316
u8 gOled_param[50] = { 0x80,0xAE,0x80,0x00,0x80,0x10,0x80,0x40,0x80,0xB0,0x80,
0x81,0x80,0xFF,0x80,0xA0,0x80,0xA6,0x80,0xA8,0x80,0x1F,
0x80,0xC8,0x80,0xD3,0x80,0x00,0x80,0xD5,0x80,0x80,0x80,
0xD9,0x80,0x22,0x80,0xDA,0x80,0x12,0x80,0xDB,0x80,0x40,
0x80,0x8D,0x80,0x14,0x80,0xAF,
};
#else
u8 gOled_param[46] = { 0x80,0xAE,0x80,0xD5,0x80,0x52,0x80,0xA8,0x80,0x0f,0x80,
0xC0,0x80,0xD3,0x80,0x00,0x80,0x40,0x80,0xA0,0x80,0x8D,
0x80,0x14,0x80,0xDA,0x80,0x02,0x80,0x81,0x80,0x33,0x80,
0xD9,0x80,0xF1,0x80,0xDB,0x80,0x30,0x80,0xA4,0x80,0XA6,
0x80,0xAF
};
//MiniDSO startup logo
const u8 Mini[] = {/*12*16*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE,
0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE,
0xFE, 0xFE, 0xFC, 0x78, 0x30, 0x80, 0xC0, 0xC0, 0x00, 0x18, 0x9C, 0xCE,
0xE6, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xE0,
0xF0, 0xF8, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x03, 0x07, 0x0F, 0x1F,
0x3F, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x03, 0x07, 0x07,
0x03, 0x19, 0x1C, 0x0E, 0x67, 0x73, 0x39, 0x1C, 0x0E, 0x07, 0x03, 0x01,
0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, /*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\LOGOIN.BMP.bmp",0*/
};
#endif
//Setup params depending on oled model
#ifdef SSD1316
u8 gOled_param[50] = {0x80,0xAE,0x80,0x00,0x80,0x10,0x80,0x40,0x80,0xB0,0x80,
0x81,0x80,0xFF,0x80,0xA0,0x80,0xA6,0x80,0xA8,0x80,0x1F,
0x80,0xC8,0x80,0xD3,0x80,0x00,0x80,0xD5,0x80,0x80,0x80,
0xD9,0x80,0x22,0x80,0xDA,0x80,0x12,0x80,0xDB,0x80,0x40,
0x80,0x8D,0x80,0x14,0x80,0xAF,
};
#else
u8 gOled_param[46] = { 0x80, 0xAE, 0x80, 0xD5, 0x80, 0x52, 0x80, 0xA8, 0x80,
0x0f, 0x80, 0xC0, 0x80, 0xD3, 0x80, 0x00, 0x80, 0x40, 0x80, 0xA0, 0x80,
0x8D, 0x80, 0x14, 0x80, 0xDA, 0x80, 0x02, 0x80, 0x81, 0x80, 0x33, 0x80,
0xD9, 0x80, 0xF1, 0x80, 0xDB, 0x80, 0x30, 0x80, 0xA4, 0x80, 0XA6, 0x80,
0xAF };
#endif
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sc_Pt
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD>Աȶ<D4B1>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Co<43><6F>Ļ<EFBFBD>ԱȶȲ<C8B6><C8B2><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sc_Pt
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD>Աȶ<D4B1>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Co<43><6F>Ļ<EFBFBD>ԱȶȲ<C8B6><C8B2><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Sc_Pt(u8 Co) //<2F><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
{
u8 pt[4] = {0x80,0x81,0x80,Co};
u8 pt[4] = { 0x80, 0x81, 0x80, Co };
I2C_PageWrite(pt,4,DEVICEADDR_OLED);
I2C_PageWrite(pt, 4, DEVICEADDR_OLED);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DisplayOn
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>OLED<45><44>ʾ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Oled_DisplayOn(void)
{
u8 data[6] = {0x80,0X8D,0x80,0X14,0x80,0XAF};
Function: Oled_DisplayOn
Description:Turn on the Oled display
*******************************************************************************/
void Oled_DisplayOn(void) {
u8 data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF };
I2C_PageWrite(data,6,DEVICEADDR_OLED);
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DisplayOff
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A>ر<EFBFBD>OLED<45><44>ʾ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Oled_DisplayOff(void)
{
u8 data[6] = {0x80,0X8D,0x80,0X10,0x80,0XAE};
Function: Oled_DisplayOff
Description:Turn off the Oled display
*******************************************************************************/
void Oled_DisplayOff(void) {
u8 data[6] = { 0x80, 0X8D, 0x80, 0X10, 0x80, 0XAE };
I2C_PageWrite(data,6,DEVICEADDR_OLED);
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Data_Command
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ʾ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB4AB>OLED
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:wide <20><>,ptr <20><>ָ<EFBFBD><D6B8>
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>
*******************************************************************************/
u8* Data_Command(u8 wide,u8* ptr)
{
int i;
u8 tx_data[128];
tx_data[0] = 0x40;
wide += 1;
for(i = 1; i < wide; i++) tx_data[i] = *ptr++;
I2C_PageWrite(tx_data,wide,DEVICEADDR_OLED);
return ptr;
Function: Data_Command
Description: write a command to the Oled display
Input: number of bytes to write, array to write
Output:
*******************************************************************************/
u8* Data_Command(u8 wide, u8* ptr) {
int i;
u8 tx_data[128];
//here are are inserting the data write command at the beginning
tx_data[0] = 0x40;
wide += 1;
for (i = 1; i < wide; i++) //Loop through the array of data
tx_data[i] = *ptr++;
I2C_PageWrite(tx_data, wide, DEVICEADDR_OLED); //write out the buffer
return ptr;
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_ShowPos
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><D2AA>ʾ<EFBFBD><CABE><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:x:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,y:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0,8,16,24)
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Set_ShowPos(u8 x,u8 y)
{
u8 pos_param[8] = { 0x80,0xB0,0x80,0x21,0x80,0x20,0x80,0x7F };
Function:Set_ShowPos
Description:Set the current position in GRAM that we are drawing to
Input:x,y co-ordinates
*******************************************************************************/
void Set_ShowPos(u8 x, u8 y) {
u8 pos_param[8] = { 0x80, 0xB0, 0x80, 0x21, 0x80, 0x20, 0x80, 0x7F };
pos_param[5] = x + 32;
pos_param[1] += y;
pos_param[5] = x + 32;
pos_param[1] += y;
I2C_PageWrite(pos_param,8,DEVICEADDR_OLED);
I2C_PageWrite(pos_param, 8, DEVICEADDR_OLED);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Oled_DrawArea
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʾһ<CABE><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: x0:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
y0:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0,8,16,24)
wide:<3A><>ʾ<EFBFBD><CABE><EFBFBD>ݿ<EFBFBD><DDBF>
high:<3A><>ʾ<EFBFBD><CABE><EFBFBD>ݸ߶<DDB8>
ptr:<3A><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ָ<EFBFBD><D6B8>
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>
*******************************************************************************/
u8* Oled_DrawArea(u8 x0,u8 y0,u8 wide, u8 high,u8* ptr)
{
u8 m,n,y;
Function:Oled_DrawArea
Description:
Inputs:(x,y) start point, (width,height) of enclosing rect, pointer to data
Output: last byte written out
*******************************************************************************/
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr) {
u8 m, n, y;
n = y0 + high;
if(y0 % 8 == 0) m = y0 / 8;
else m = y0 / 8 + 1;
n = y0 + high;
if (y0 % 8 == 0)
m = y0 / 8;
else
m = y0 / 8 + 1;
if(n % 8 == 0) y = n / 8;
else y = n / 8 + 1;
if (n % 8 == 0)
y = n / 8;
else
y = n / 8 + 1;
for(; m < y; m++) {
Set_ShowPos(x0,m);
ptr = Data_Command(wide,ptr);
}
return ptr;
for (; m < y; m++) {
Set_ShowPos(x0, m);
ptr = Data_Command(wide, ptr);
}
return ptr;
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Clean_Char
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wideλ<65><CEBB>Ϊk<CEAA><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>λ<EFBFBD><CEBB>wideΪ<65><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Clean_Char(int k,u8 wide)
{
int i;
u8 tx_data[128];
Function:Clean_Char
Description:Overwries a square to off, used to overwrite a char
Inputs:(k) input X position char starts at, (wide) how many pixels wide the char is
*******************************************************************************/
void Clean_Char(int k, u8 wide) {
int i;
u8 tx_data[128];
memset(&tx_data[0],0,wide);
for(i = 0; i < 2; i++) {
Oled_DrawArea(k,i * 8,wide,8,tx_data);
}
memset(&tx_data[0], 0, wide);
for (i = 0; i < 2; i++) {
Oled_DrawArea(k, i * 8, wide, 8, tx_data);
}
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GPIO_Init_OLED
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC>LED<45>˿<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void GPIO_Init_OLED(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
Function:GPIO_Init_OLED
Description:Init the outputs as needed for the OLED (in this case the RST line)
*******************************************************************************/
void GPIO_Init_OLED(void) {
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Init_Oled
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC>LED<45><44><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Init_Oled(void)
{
u8 param_len;
Function: Init_Oled
Description: Initalizes the Oled screen
*******************************************************************************/
void Init_Oled(void) {
u8 param_len;
OLED_RST();
Delay_Ms(2);
OLED_ACT();
Delay_Ms(2);
OLED_RST();
Delay_Ms(2);
OLED_ACT();
Delay_Ms(2);
#ifdef SSD1316
param_len = 50;
param_len = 50;
#else
param_len = 46;
param_len = 46;
#endif
I2C_PageWrite((u8 *)gOled_param,param_len,DEVICEADDR_OLED);
I2C_PageWrite((u8 *) gOled_param, param_len, DEVICEADDR_OLED);
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Clear_Screen
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Clear_Screen(void)
{
u8 tx_data[128];
u8 i,wd;
Function:Clear_Screen
Description:Clear the entire screen to off (black)
*******************************************************************************/
void Clear_Screen(void) {
u8 tx_data[128];
u8 i, wd;
#ifdef SSD1316
wd = 32;
wd = 32;
#else
wd = 16;
wd = 16;
#endif
memset(&tx_data[0],0,128);
for(i = 0; i < wd / 8; i++) {
Oled_DrawArea(0,i * 8,128,8,tx_data);
}
memset(&tx_data[0], 0, 128);
for (i = 0; i < wd / 8; i++) {
Oled_DrawArea(0, i * 8, 128, 8, tx_data);
}
}
/*******************************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Display_BG
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ΪLOGOIN.BMP<4D><50>ͼƬ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
*******************************************************************************/
void Display_BG(void)
{
u8 i,j,k,m,n,p,ch,Palette = 1;
u8* bmpfile;
u16 filelen;
u16* Root_addr = 0;
u8 *ptr = 0;
u8 g_au8TxData[128];
Function:Display_BG
Description:Display the bootup graphics (the logo)
* Reads the file if present in the filesystem otherwise uses hard coded ones
*******************************************************************************/
void Display_BG(void) {
u8 i, j, k, m, n, p, ch, Palette = 1;
u8* bmpfile;
u16 filelen;
u16* Root_addr = 0;
u8 *ptr = 0;
u8 g_au8TxData[128];
if((bmpfile = SearchFile("LOGOIN BMP",&filelen,Root_addr))) {
if(bmpfile[0] == 'B' && bmpfile[1] == 'M' ) {
if((bmpfile[0x36] == 0xFF) && (bmpfile[0x37] == 0xFF) && (bmpfile[0x38] == 0xFF)) {
Palette = 0;
}
memset(&g_au8TxData[1],0,127);
p = 0x1;
for(i = 15; i >= 8; i--) {
m = 0;
for(j = 0; j < 12; j++) {
ch = bmpfile[0x3E + i * 12 + j];
n = 0x80;
for(k = 0; k < 8; k++) {
if(Palette) {
if(!(ch & n)) g_au8TxData[m + 1] |= p;
} else {
if((ch & n)) g_au8TxData[m + 1] |= p;
}
m++;
n >>= 1;
}
}
p <<= 1;
}
Oled_DrawArea(0,0,96,8,g_au8TxData);
Clear_Watchdog();
if ((bmpfile = SearchFile("LOGOIN BMP", &filelen, Root_addr))) {
if (bmpfile[0] == 'B' && bmpfile[1] == 'M') {
if ((bmpfile[0x36] == 0xFF) && (bmpfile[0x37] == 0xFF)
&& (bmpfile[0x38] == 0xFF)) {
Palette = 0;
}
memset(&g_au8TxData[1], 0, 127);
p = 0x1;
for (i = 15; i >= 8; i--) {
m = 0;
for (j = 0; j < 12; j++) {
ch = bmpfile[0x3E + i * 12 + j];
n = 0x80;
for (k = 0; k < 8; k++) {
if (Palette) {
if (!(ch & n))
g_au8TxData[m + 1] |= p;
} else {
if ((ch & n))
g_au8TxData[m + 1] |= p;
}
m++;
n >>= 1;
}
}
p <<= 1;
}
Oled_DrawArea(0, 0, 96, 8, g_au8TxData);
Clear_Watchdog();
memset(&g_au8TxData[1],0,127);
p = 0x1;
for(i = 0; i < 8; i++) {
m = 0;
for(j = 0; j < 12; j++) {
ch = bmpfile[0x3E + (7 - i) * 12 + j];
n = 0x80;
for(k = 0; k < 8; k++) {
if(Palette) {
if(!(ch & n)) g_au8TxData[m + 1] |= p;
} else {
if((ch & n)) g_au8TxData[m + 1] |= p;
}
m++;
n >>= 1;
}
}
p <<= 1;
}
Oled_DrawArea(0,8,96,8,g_au8TxData);
Delay_Ms(1000);
Clear_Watchdog();
return;
}
} else {
memset(&g_au8TxData[1], 0, 127);
p = 0x1;
for (i = 0; i < 8; i++) {
m = 0;
for (j = 0; j < 12; j++) {
ch = bmpfile[0x3E + (7 - i) * 12 + j];
n = 0x80;
for (k = 0; k < 8; k++) {
if (Palette) {
if (!(ch & n))
g_au8TxData[m + 1] |= p;
} else {
if ((ch & n))
g_au8TxData[m + 1] |= p;
}
m++;
n >>= 1;
}
}
p <<= 1;
}
Oled_DrawArea(0, 8, 96, 8, g_au8TxData);
Delay_Ms(1000);
Clear_Watchdog();
return;
}
} else {
//Check the #defines for which one to use
#ifdef MFTSEEED
ptr = (u8*)Seeed;
ptr = (u8*)Seeed;
#else
ptr = (u8*)Mini;
ptr = (u8*) Mini;
#endif
Oled_DrawArea(0,0,96,16,ptr);
Delay_Ms(1000);
Clear_Watchdog();
}
Oled_DrawArea(0, 0, 96, 16, ptr);
Delay_Ms(1000);
Clear_Watchdog();
}
}
/******************************** END OF FILE *********************************/

File diff suppressed because it is too large Load Diff