增加了有关SPI-flash、OLED的测试代码,并去掉LED2,修改了PWMA、PWMB、BIN1、BIN2、OLED的SDA、SCL的引脚位置,新增USB的D+和D-规划引脚,并提交制板
@ -66,7 +66,13 @@
|
||||
"mw_motor.h": "c",
|
||||
"app_motor.h": "c",
|
||||
"mw_ir_controller.h": "c",
|
||||
"app_ir_controller.h": "c"
|
||||
"app_ir_controller.h": "c",
|
||||
"bsp_oled.h": "c",
|
||||
"oled.h": "c",
|
||||
"w25q64.h": "c",
|
||||
"bsp_flash.h": "c",
|
||||
"myspi.h": "c",
|
||||
"w25q64_ins.h": "c"
|
||||
},
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
motor_state_ENUM e_motor_state = motor_state_stop;
|
||||
int8_t motor_speed = 100;
|
||||
int8_t motor_speed = 80;
|
||||
/*************************************************************************************
|
||||
* @brief 电机驱动器根据当前电机状态,进行相应的动作
|
||||
*
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include "bsp_timer.h"
|
||||
#include "bsp_usart.h"
|
||||
#include "bsp_motor.h"
|
||||
#include "bsp_oled.h"
|
||||
#include "bsp_flash.h"
|
||||
|
||||
// #include "bsp.h"
|
||||
|
||||
@ -44,6 +46,11 @@ void bsp_init(void)
|
||||
bsp_usart_IrController_init();
|
||||
|
||||
bsp_InitMotor();
|
||||
|
||||
bsp_oled_init();
|
||||
|
||||
bsp_flash_init();
|
||||
|
||||
// bsp_InitTimer();
|
||||
// bsp_usart_1_init(115200);
|
||||
// bsp_Init();
|
||||
|
||||
6
Code/bsp/inc/bsp_flash.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __BSP_FLASH_H__
|
||||
#define __BSP_FLASH_H__
|
||||
|
||||
void bsp_flash_init(void);
|
||||
|
||||
#endif
|
||||
@ -5,7 +5,7 @@
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED2,
|
||||
// LED2,
|
||||
RGB_RED,
|
||||
RGB_GREEN,
|
||||
RGB_BLUE,
|
||||
|
||||
9
Code/bsp/inc/bsp_oled.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __BSP_OLED_H__
|
||||
#define __BSP_OLED_H__
|
||||
|
||||
#include "OLED.h"
|
||||
|
||||
void bsp_oled_init(void);
|
||||
|
||||
|
||||
#endif
|
||||
40
Code/bsp/src/bsp_flash.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include "bsp_flash.h"
|
||||
#include "W25Q64.h"
|
||||
#include "bsp_oled.h"
|
||||
void bsp_flash_init(void)
|
||||
{
|
||||
uint8_t MID; //定义用于存放MID号的变量
|
||||
uint16_t DID; //定义用于存放DID号的变量
|
||||
|
||||
uint8_t ArrayWrite[] = {0x01, 0x02, 0x04, 0x08}; //定义要写入数据的测试数组
|
||||
uint8_t ArrayRead[4]; //定义要读取数据的测试数组
|
||||
|
||||
W25Q64_Init(); //W25Q64初始化
|
||||
|
||||
/*显示静态字符串*/
|
||||
OLED_ShowString(1, 1, "MID: DID:");
|
||||
OLED_ShowString(2, 1, "W:");
|
||||
OLED_ShowString(3, 1, "R:");
|
||||
|
||||
/*显示ID号*/
|
||||
W25Q64_ReadID(&MID, &DID); //获取W25Q64的ID号
|
||||
OLED_ShowHexNum(1, 5, MID, 2); //显示MID
|
||||
OLED_ShowHexNum(1, 12, DID, 4); //显示DID
|
||||
|
||||
/*W25Q64功能函数测试*/
|
||||
W25Q64_SectorErase(0x000000); //扇区擦除
|
||||
W25Q64_PageProgram(0x000000, ArrayWrite, 4); //将写入数据的测试数组写入到W25Q64中
|
||||
|
||||
W25Q64_ReadData(0x000000, ArrayRead, 4); //读取刚写入的测试数据到读取数据的测试数组中
|
||||
|
||||
/*显示数据*/
|
||||
OLED_ShowHexNum(2, 3, ArrayWrite[0], 2); //显示写入数据的测试数组
|
||||
OLED_ShowHexNum(2, 6, ArrayWrite[1], 2);
|
||||
OLED_ShowHexNum(2, 9, ArrayWrite[2], 2);
|
||||
OLED_ShowHexNum(2, 12, ArrayWrite[3], 2);
|
||||
|
||||
OLED_ShowHexNum(3, 3, ArrayRead[0], 2); //显示读取数据的测试数组
|
||||
OLED_ShowHexNum(3, 6, ArrayRead[1], 2);
|
||||
OLED_ShowHexNum(3, 9, ArrayRead[2], 2);
|
||||
OLED_ShowHexNum(3, 12, ArrayRead[3], 2);
|
||||
}
|
||||
@ -56,11 +56,11 @@ void bsp_led_on(uint8_t led_no)
|
||||
// GPIO_PORT_LED1->BRR = GPIO_PIN_LED1;
|
||||
GPIO_PORT_LED1->BSRR |= GPIO_PIN_LED1;
|
||||
}
|
||||
if (led_no == (LED2))
|
||||
{
|
||||
// STM32F103C8T6开发板 1是亮,0是灭
|
||||
GPIO_PORT_LED2->BSRR |= GPIO_PIN_LED2;
|
||||
}
|
||||
// if (led_no == (LED2))
|
||||
// {
|
||||
// // STM32F103C8T6开发板 1是亮,0是灭
|
||||
// GPIO_PORT_LED2->BSRR |= GPIO_PIN_LED2;
|
||||
// }
|
||||
}
|
||||
/*************************************************************************************
|
||||
* @brief 关闭Led
|
||||
@ -76,10 +76,10 @@ void bsp_led_off(uint8_t led_no)
|
||||
// STM32F103C8T6开发板 1是亮,0是灭
|
||||
GPIO_PORT_LED1->BRR = GPIO_PIN_LED1;
|
||||
}
|
||||
else if(led_no == LED2)
|
||||
{
|
||||
GPIO_PORT_LED2->BRR = GPIO_PIN_LED2;
|
||||
}
|
||||
// else if(led_no == LED2)
|
||||
// {
|
||||
// GPIO_PORT_LED2->BRR = GPIO_PIN_LED2;
|
||||
// }
|
||||
else
|
||||
{
|
||||
;
|
||||
@ -99,10 +99,10 @@ void bsp_led_toggle(uint8_t led_no)
|
||||
{
|
||||
GPIO_PORT_LED1->ODR ^= GPIO_PIN_LED1;
|
||||
}
|
||||
else if (led_no == LED2)
|
||||
{
|
||||
GPIO_PORT_LED2->ODR ^= GPIO_PIN_LED2;
|
||||
}
|
||||
// else if (led_no == LED2)
|
||||
// {
|
||||
// GPIO_PORT_LED2->ODR ^= GPIO_PIN_LED2;
|
||||
// }
|
||||
else
|
||||
{
|
||||
;
|
||||
@ -124,11 +124,11 @@ uint8_t bsp_get_led_ttlState(led_type_enum led_no)
|
||||
// GPIO_PORT_LED1->BRR = GPIO_PIN_LED1;
|
||||
retVal = GPIO_PORT_LED1->ODR & GPIO_PIN_LED1;
|
||||
}
|
||||
else if(led_no == (LED2))
|
||||
{
|
||||
// STM32F103C8T6开发板 1是亮,0是灭
|
||||
retVal = GPIO_PORT_LED2->ODR & GPIO_PIN_LED2;
|
||||
}
|
||||
// else if(led_no == (LED2))
|
||||
// {
|
||||
// // STM32F103C8T6开发板 1是亮,0是灭
|
||||
// retVal = GPIO_PORT_LED2->ODR & GPIO_PIN_LED2;
|
||||
// }
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@ -161,21 +161,21 @@ void bsp_led1_init(void)
|
||||
|
||||
void bsp_led2_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* 打开GPIO时钟 */
|
||||
RCC_APB2PeriphClockCmd(RCC_GPIO_LED2, ENABLE);
|
||||
// RCC_APB2PeriphClockCmd(RCC_GPIO_LED2, ENABLE);
|
||||
|
||||
/*
|
||||
配置所有的LED指示灯GPIO为推挽输出模式
|
||||
由于将GPIO设置为输出时,GPIO输出寄存器的值缺省是0,因此会驱动LED点亮.
|
||||
这是我不希望的,因此在改变GPIO为输出前,先关闭LED指示灯
|
||||
*/
|
||||
bsp_led_off(LED2);
|
||||
/* LED 2*/
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_LED2;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设为 输出推挽模式 */
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO口最大速度 */
|
||||
GPIO_Init(GPIO_PORT_LED2, &GPIO_InitStructure);
|
||||
// /*
|
||||
// 配置所有的LED指示灯GPIO为推挽输出模式
|
||||
// 由于将GPIO设置为输出时,GPIO输出寄存器的值缺省是0,因此会驱动LED点亮.
|
||||
// 这是我不希望的,因此在改变GPIO为输出前,先关闭LED指示灯
|
||||
// */
|
||||
// bsp_led_off(LED2);
|
||||
// /* LED 2*/
|
||||
// GPIO_InitStructure.GPIO_Pin = GPIO_PIN_LED2;
|
||||
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设为 输出推挽模式 */
|
||||
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO口最大速度 */
|
||||
// GPIO_Init(GPIO_PORT_LED2, &GPIO_InitStructure);
|
||||
}
|
||||
/*************************************************************************************
|
||||
* @brief RGB 红灯初始化
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
|
||||
#include "stm32f10x.h" // Device header
|
||||
#include "stm32f10x_gpio.h"
|
||||
|
||||
#include "stm32f10x_rcc.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
/* A IN1 */
|
||||
#define A_IN1_GPIO_PORT (GPIOA)
|
||||
#define A_IN1_GPIO_PIN (GPIO_Pin_4)
|
||||
@ -13,24 +14,24 @@
|
||||
#define A_IN2_GPIO_PORT (GPIOA)
|
||||
#define A_IN2_GPIO_PIN (GPIO_Pin_5)
|
||||
/* B IN1 */
|
||||
#define B_IN1_GPIO_PORT (GPIOB)
|
||||
#define B_IN1_GPIO_PIN (GPIO_Pin_12)
|
||||
#define B_IN1_GPIO_PORT (GPIOA)
|
||||
#define B_IN1_GPIO_PIN (GPIO_Pin_1)
|
||||
/* B IN2 */
|
||||
#define B_IN2_GPIO_PORT (GPIOB)
|
||||
#define B_IN2_GPIO_PIN (GPIO_Pin_13)
|
||||
#define B_IN2_GPIO_PORT (GPIOA)
|
||||
#define B_IN2_GPIO_PIN (GPIO_Pin_8)
|
||||
|
||||
/* 电机驱动PWM定时器 */
|
||||
#define TIM_MOTOR TIM2
|
||||
#define TIM_MOTOR_IRQn TIM2_IRQn
|
||||
#define TIM_MOTOR_PERIPH_RCC RCC_APB1Periph_TIM2
|
||||
#define TIM_MOTOR TIM4
|
||||
#define TIM_MOTOR_IRQn TIM4_IRQn
|
||||
#define TIM_MOTOR_PERIPH_RCC RCC_APB1Periph_TIM4
|
||||
/* PWMA */
|
||||
#define TIM_MOTOR_PWMA_GPIO_RCC RCC_APB2Periph_GPIOA
|
||||
#define TIM_MOTOR_PWMA_GPIO_PORT GPIOA
|
||||
#define TIM_MOTOR_PWMA_GPIO_PIN GPIO_Pin_1
|
||||
#define TIM_MOTOR_PWMA_GPIO_RCC RCC_APB2Periph_GPIOB
|
||||
#define TIM_MOTOR_PWMA_GPIO_PORT GPIOB
|
||||
#define TIM_MOTOR_PWMA_GPIO_PIN GPIO_Pin_8
|
||||
/* PWMB */
|
||||
#define TIM_MOTOR_PWMB_GPIO_RCC RCC_APB2Periph_GPIOA
|
||||
#define TIM_MOTOR_PWMB_GPIO_PORT GPIOA
|
||||
#define TIM_MOTOR_PWMB_GPIO_PIN GPIO_Pin_0
|
||||
#define TIM_MOTOR_PWMB_GPIO_RCC RCC_APB2Periph_GPIOB
|
||||
#define TIM_MOTOR_PWMB_GPIO_PORT GPIOB
|
||||
#define TIM_MOTOR_PWMB_GPIO_PIN GPIO_Pin_9
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
@ -42,8 +43,19 @@
|
||||
void bsp_InitGPIO_MotorOut(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
// 时钟初始化
|
||||
if(A_IN1_GPIO_PORT == GPIOA || A_IN2_GPIO_PORT == GPIOA || B_IN1_GPIO_PORT == GPIOA || B_IN2_GPIO_PORT == GPIOA)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
}
|
||||
if(A_IN1_GPIO_PORT == GPIOB || A_IN2_GPIO_PORT == GPIOB || B_IN1_GPIO_PORT == GPIOB || B_IN2_GPIO_PORT == GPIOB)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
}
|
||||
if(A_IN1_GPIO_PORT == GPIOC || A_IN2_GPIO_PORT == GPIOC || B_IN1_GPIO_PORT == GPIOC || B_IN2_GPIO_PORT == GPIOC)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
/* AIN1 初始化 */
|
||||
@ -117,9 +129,9 @@ void bsp_InitGPIO_MotorOut(void)
|
||||
TIM_OCInitStructure.TIM_Pulse = 0; //CCR 占空比
|
||||
// 应用至TIM2_CHx[1,7](@ref)
|
||||
/* PWMA */
|
||||
TIM_OC2Init(TIM_MOTOR, &TIM_OCInitStructure);
|
||||
TIM_OC3Init(TIM_MOTOR, &TIM_OCInitStructure);
|
||||
/* PWMB */
|
||||
TIM_OC1Init(TIM_MOTOR, &TIM_OCInitStructure);
|
||||
TIM_OC4Init(TIM_MOTOR, &TIM_OCInitStructure);
|
||||
|
||||
TIM_ARRPreloadConfig(TIM_MOTOR, ENABLE);
|
||||
/* 6. TIMx enable counter */
|
||||
@ -227,7 +239,7 @@ void bsp_BIN2_OFF(void)
|
||||
*************************************************************************************/
|
||||
void bsp_changeLeftMotorSpeed(uint16_t Compare)
|
||||
{
|
||||
TIM_SetCompare1(TIM_MOTOR, Compare);
|
||||
TIM_SetCompare3(TIM_MOTOR, Compare);
|
||||
}
|
||||
/*************************************************************************************
|
||||
* @brief 通过修改pwm,来修改右轮电机的速度
|
||||
@ -238,6 +250,6 @@ void bsp_changeLeftMotorSpeed(uint16_t Compare)
|
||||
*************************************************************************************/
|
||||
void bsp_changeRightMotorSpeed(uint16_t Compare)
|
||||
{
|
||||
TIM_SetCompare2(TIM_MOTOR, Compare);
|
||||
TIM_SetCompare4(TIM_MOTOR, Compare);
|
||||
}
|
||||
|
||||
|
||||
25
Code/bsp/src/bsp_oled.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "bsp_oled.h"
|
||||
// #include "OLED.h"
|
||||
|
||||
|
||||
void bsp_oled_init(void)
|
||||
{
|
||||
OLED_Init();
|
||||
|
||||
/*OLED显示*/
|
||||
// OLED_ShowChar(1, 1, 'A'); //1行1列显示字符A
|
||||
|
||||
// OLED_ShowString(1, 3, "HelloWorld!"); //1行3列显示字符串HelloWorld!
|
||||
|
||||
// OLED_ShowNum(2, 1, 12345, 5); //2行1列显示十进制数字12345,长度为5
|
||||
|
||||
// OLED_ShowSignedNum(2, 7, -66, 2); //2行7列显示有符号十进制数字-66,长度为2
|
||||
|
||||
// OLED_ShowHexNum(3, 1, 0xAA55, 4); //3行1列显示十六进制数字0xA5A5,长度为4
|
||||
|
||||
// OLED_ShowBinNum(4, 1, 0xAA55, 16); //4行1列显示二进制数字0xA5A5,长度为16
|
||||
// //C语言无法直接写出二进制数字,故需要用十六进制表示
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -36,12 +36,12 @@
|
||||
#define TIM_HARD TIM3
|
||||
#define TIM_HARD_IRQn TIM3_IRQn
|
||||
#define TIM_HARD_RCC RCC_APB1Periph_TIM3
|
||||
/* PWM输出比较 定时器 */
|
||||
#define TIM_PWM TIM4
|
||||
#define TIM_PWM_IRQn TIM4_IRQn
|
||||
#define TIM_PWM_RCC RCC_APB1Periph_TIM4
|
||||
#define TIM_PWM_CH1_PORT GPIOB
|
||||
#define TIM_PWM_CH1_PIN GPIO_Pin_6
|
||||
// /* PWM输出比较 定时器 */
|
||||
// #define TIM_PWM TIM4
|
||||
// #define TIM_PWM_IRQn TIM4_IRQn
|
||||
// #define TIM_PWM_RCC RCC_APB1Periph_TIM4
|
||||
// #define TIM_PWM_CH1_PORT GPIOB
|
||||
// #define TIM_PWM_CH1_PIN GPIO_Pin_6
|
||||
|
||||
|
||||
// /* 测试 TIM2_ETR 是否使用重映射功能 */
|
||||
@ -419,68 +419,68 @@ void bsp_InitHardTimer(void)
|
||||
|
||||
void bsp_pwm_init(void)
|
||||
{
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// NVIC_InitTypeDef NVIC_InitStructure; /* 中断结构体在 misc.h 中定义 */
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure;
|
||||
/* 1. 使能TIM时钟 */
|
||||
RCC_APB1PeriphClockCmd(TIM_PWM_RCC, ENABLE);
|
||||
/* 2. 使用内部时钟 */
|
||||
TIM_InternalClockConfig(TIM_PWM);
|
||||
/* 3. 初始化GPIO */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
GPIO_StructInit(&GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = TIM_PWM_CH1_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(TIM_PWM_CH1_PORT, &GPIO_InitStructure);
|
||||
/* 3. 配置时基单元 */
|
||||
/*-----------------------------------------------------------------------
|
||||
system_stm32f10x.c 文件中 void SetSysClock(void) 函数对时钟的配置如下:
|
||||
// TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
// GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// // NVIC_InitTypeDef NVIC_InitStructure; /* 中断结构体在 misc.h 中定义 */
|
||||
// TIM_OCInitTypeDef TIM_OCInitStructure;
|
||||
// /* 1. 使能TIM时钟 */
|
||||
// RCC_APB1PeriphClockCmd(TIM_PWM_RCC, ENABLE);
|
||||
// /* 2. 使用内部时钟 */
|
||||
// TIM_InternalClockConfig(TIM_PWM);
|
||||
// /* 3. 初始化GPIO */
|
||||
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
// GPIO_StructInit(&GPIO_InitStructure);
|
||||
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
// GPIO_InitStructure.GPIO_Pin = TIM_PWM_CH1_PIN;
|
||||
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
// GPIO_Init(TIM_PWM_CH1_PORT, &GPIO_InitStructure);
|
||||
// /* 3. 配置时基单元 */
|
||||
// /*-----------------------------------------------------------------------
|
||||
// system_stm32f10x.c 文件中 void SetSysClock(void) 函数对时钟的配置如下:
|
||||
|
||||
HCLK = SYSCLK / 1 (AHBPeriph)
|
||||
PCLK2 = HCLK / 1 (APB2Periph)
|
||||
PCLK1 = HCLK / 2 (APB1Periph)
|
||||
// HCLK = SYSCLK / 1 (AHBPeriph)
|
||||
// PCLK2 = HCLK / 1 (APB2Periph)
|
||||
// PCLK1 = HCLK / 2 (APB1Periph)
|
||||
|
||||
因为APB1 prescaler != 1, 所以 APB1上的TIMxCLK = PCLK1 x 2 = SystemCoreClock;
|
||||
因为APB2 prescaler = 1, 所以 APB2上的TIMxCLK = PCLK2 = SystemCoreClock;
|
||||
// 因为APB1 prescaler != 1, 所以 APB1上的TIMxCLK = PCLK1 x 2 = SystemCoreClock;
|
||||
// 因为APB2 prescaler = 1, 所以 APB2上的TIMxCLK = PCLK2 = SystemCoreClock;
|
||||
|
||||
注意TIM_Prescaler 和 TIM_Period 不要溢出(0-65535)
|
||||
// 注意TIM_Prescaler 和 TIM_Period 不要溢出(0-65535)
|
||||
|
||||
----------------------------------------------------------------------- */
|
||||
// 时基单元定义 此处定义1ms的
|
||||
TIM_TimeBaseStructure.TIM_Period = (10 - 1); // 周期 ARR自动重装器的值
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (36 - 1); // PSC预分频器的值
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; // 计数器模式
|
||||
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; // 重复计数器的值,高级定时器才有
|
||||
TIM_TimeBaseInit(TIM_PWM, &TIM_TimeBaseStructure);
|
||||
// ----------------------------------------------------------------------- */
|
||||
// // 时基单元定义 此处定义1ms的
|
||||
// TIM_TimeBaseStructure.TIM_Period = (10 - 1); // 周期 ARR自动重装器的值
|
||||
// TIM_TimeBaseStructure.TIM_Prescaler = (36 - 1); // PSC预分频器的值
|
||||
// TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||
// TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; // 计数器模式
|
||||
// TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; // 重复计数器的值,高级定时器才有
|
||||
// TIM_TimeBaseInit(TIM_PWM, &TIM_TimeBaseStructure);
|
||||
|
||||
TIM_OCStructInit(&TIM_OCInitStructure);
|
||||
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
|
||||
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
|
||||
TIM_OCInitStructure.TIM_Pulse = 0;
|
||||
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
|
||||
TIM_OC1Init(TIM_PWM, &TIM_OCInitStructure);
|
||||
// /* 4. 开启更新中断到NVIC的通路 */
|
||||
// TIM_ClearITPendingBit(TIM_PWM, TIM_IT_Update);
|
||||
// // 在开启更新中断之前,先把这个更新中断清掉,防止一开始就触发了更新中断
|
||||
// TIM_ITConfig(TIM_PWM, TIM_IT_Update, ENABLE);
|
||||
// 启用影子寄存器
|
||||
TIM_ARRPreloadConfig(TIM_PWM, ENABLE);
|
||||
// /* 5. 配置TIM定时中断 (Update) */
|
||||
// NVIC_InitStructure.NVIC_IRQChannel = TIM_HARD_IRQn;
|
||||
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4; /* 比串口优先级低 */
|
||||
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
// NVIC_Init(&NVIC_InitStructure);
|
||||
/* 6. TIMx enable counter */
|
||||
TIM_Cmd(TIM_PWM, ENABLE);
|
||||
// TIM_OCStructInit(&TIM_OCInitStructure);
|
||||
// TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
|
||||
// TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
|
||||
// TIM_OCInitStructure.TIM_Pulse = 0;
|
||||
// TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
|
||||
// TIM_OC1Init(TIM_PWM, &TIM_OCInitStructure);
|
||||
// // /* 4. 开启更新中断到NVIC的通路 */
|
||||
// // TIM_ClearITPendingBit(TIM_PWM, TIM_IT_Update);
|
||||
// // // 在开启更新中断之前,先把这个更新中断清掉,防止一开始就触发了更新中断
|
||||
// // TIM_ITConfig(TIM_PWM, TIM_IT_Update, ENABLE);
|
||||
// // 启用影子寄存器
|
||||
// TIM_ARRPreloadConfig(TIM_PWM, ENABLE);
|
||||
// // /* 5. 配置TIM定时中断 (Update) */
|
||||
// // NVIC_InitStructure.NVIC_IRQChannel = TIM_HARD_IRQn;
|
||||
// // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4; /* 比串口优先级低 */
|
||||
// // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
// // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
// // NVIC_Init(&NVIC_InitStructure);
|
||||
// /* 6. TIMx enable counter */
|
||||
// TIM_Cmd(TIM_PWM, ENABLE);
|
||||
}
|
||||
|
||||
void bsp_change_pwm(uint8_t ucData)
|
||||
{
|
||||
TIM_SetCompare1(TIM_PWM, ucData);
|
||||
// TIM_SetCompare1(TIM_PWM, ucData);
|
||||
}
|
||||
|
||||
/*************************************************************************************
|
||||
@ -491,17 +491,17 @@ void bsp_change_pwm(uint8_t ucData)
|
||||
*************************************************************************************/
|
||||
void bsp_pwm_test_loop(void)
|
||||
{
|
||||
int8_t tmp_i = 0;
|
||||
for(tmp_i = 0; tmp_i <= 10; ++tmp_i)
|
||||
{
|
||||
bsp_change_pwm(tmp_i);
|
||||
bsp_DelayMS(50);
|
||||
}
|
||||
for(tmp_i = 10; tmp_i >= 0; tmp_i--)
|
||||
{
|
||||
bsp_change_pwm(tmp_i);
|
||||
bsp_DelayMS(50);
|
||||
}
|
||||
// int8_t tmp_i = 0;
|
||||
// for(tmp_i = 0; tmp_i <= 10; ++tmp_i)
|
||||
// {
|
||||
// bsp_change_pwm(tmp_i);
|
||||
// bsp_DelayMS(50);
|
||||
// }
|
||||
// for(tmp_i = 10; tmp_i >= 0; tmp_i--)
|
||||
// {
|
||||
// bsp_change_pwm(tmp_i);
|
||||
// bsp_DelayMS(50);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
60
Code/library/FATFS/cc936.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include "ff.h"
|
||||
#include "updatefont.h"
|
||||
#include "w25qxx.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR src, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
{
|
||||
WCHAR t[2];
|
||||
WCHAR c;
|
||||
u32 i, li, hi;
|
||||
u16 n;
|
||||
u32 gbk2uni_offset=0;
|
||||
|
||||
if (src < 0x80)c = src;//ASCII,直接不用转换.
|
||||
else
|
||||
{
|
||||
if(dir) //GBK 2 UNICODE
|
||||
{
|
||||
gbk2uni_offset=hzfont_info.ugbksize/2;
|
||||
}else //UNICODE 2 GBK
|
||||
{
|
||||
gbk2uni_offset=0;
|
||||
}
|
||||
/* Unicode to OEMCP */
|
||||
hi=hzfont_info.ugbksize/2;//对半开.
|
||||
hi =hi / 4 - 1;
|
||||
li = 0;
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
W25QXX_Read((u8*)&t,hzfont_info.ugbkaddr+i*4+gbk2uni_offset,4);//读出4个字节
|
||||
if (src == t[0]) break;
|
||||
if (src > t[0])li = i;
|
||||
else hi = i;
|
||||
}
|
||||
c = n ? t[1] : 0;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
|
||||
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
|
||||
|
||||
return tbl_lower[i] ? tbl_upper[i] : chr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
63
Code/library/FATFS/doc/css_e.css
Normal file
@ -0,0 +1,63 @@
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
|
||||
abbr {border-width: 1px;}
|
||||
|
||||
p {margin: 0 0 0.3em 1em;}
|
||||
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
|
||||
strong {}
|
||||
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
|
||||
pre span.c {color: green;}
|
||||
pre span.k {color: blue;}
|
||||
pre span.arg {font-style: italic;}
|
||||
tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
|
||||
tt.arg {font-style: italic;}
|
||||
ol {margin: 0.5em 2.5em;}
|
||||
ul {margin: 0.5em 2em;}
|
||||
dl {margin: 0.5em 1em;}
|
||||
dd {margin: 0 2em;}
|
||||
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
|
||||
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
|
||||
dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
|
||||
hr {border-width: 1px; margin: 1em;}
|
||||
div.abst {font-family: sans-serif;}
|
||||
div.para {clear: both; font-family: serif;}
|
||||
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
|
||||
.equ {text-indent: 0; margin: 1em 2em 1em;}
|
||||
.indent {margin-left: 2em;}
|
||||
.rset {float: right; margin: 0 0 0.5em 0.5em;}
|
||||
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
|
||||
ul.flat li {list-style-type: none; margin: 0;}
|
||||
a.imglnk img {border: 1px solid;}
|
||||
.iequ {white-space: nowrap; font-weight: bold;}
|
||||
.clr {clear: both;}
|
||||
.it {font-style: italic;}
|
||||
.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
|
||||
.ral {text-align: right; }
|
||||
.lal {text-align: left; }
|
||||
.cal {text-align: center; }
|
||||
|
||||
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
|
||||
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
|
||||
hr.hds {clear: both; margin-bottom: 1em;}
|
||||
|
||||
h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
|
||||
small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; }
|
||||
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
|
||||
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
|
||||
table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
|
||||
table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td { border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
66
Code/library/FATFS/doc/css_j.css
Normal file
@ -0,0 +1,66 @@
|
||||
@charset "Shift_JIS";
|
||||
/* Common style sheet for Tech Notes */
|
||||
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"MS P明朝", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
|
||||
abbr {border-width: 1px;}
|
||||
|
||||
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
|
||||
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
|
||||
strong {}
|
||||
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; background-color: white;}
|
||||
pre span.c {color: green;}
|
||||
pre span.k {color: blue;}
|
||||
pre span.arg {font-style: italic;}
|
||||
tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;}
|
||||
tt.arg {font-style: italic;}
|
||||
ol {margin: 0.5em 2.5em;}
|
||||
ul {margin: 0.5em 2em;}
|
||||
dl {margin: 0.5em 1em;}
|
||||
dd {margin: 0em 2em;}
|
||||
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;}
|
||||
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;}
|
||||
dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; letter-spacing: 0; }
|
||||
hr {border-width: 1px; margin: 1em;}
|
||||
div.abst {font-family: "MS Pゴシック",sans-serif;}
|
||||
div.para {clear: both; font-family: "MS P明朝",serif;}
|
||||
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
|
||||
.equ {text-indent: 0; margin: 1em 2em 1em;}
|
||||
.indent {margin-left: 2em;}
|
||||
.rset {float: right; margin: 0 0 0.5em 0.5em;}
|
||||
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
|
||||
ul.flat li {list-style-type: none; margin: 0;}
|
||||
a.imglnk img {border: 1px solid;}
|
||||
.iequ {white-space: nowrap; font-weight: bold;}
|
||||
.clr {clear: both;}
|
||||
.it {font-style: italic;}
|
||||
.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
|
||||
.ral {text-align: right; }
|
||||
.lal {text-align: left; }
|
||||
.cal {text-align: center; }
|
||||
|
||||
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
|
||||
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
|
||||
hr.hds {clear: both; margin-bottom: 1em;}
|
||||
|
||||
h2 {font-size: 2em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: "MS Pゴシック",sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: "MS Pゴシック",sans-serif; margin: 0.5em 0 0em;}
|
||||
small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;}
|
||||
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;}
|
||||
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
|
||||
table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
|
||||
table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td {border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
43
Code/library/FATFS/doc/img/app1.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*------------------------------------------------------------/
|
||||
/ Open or create a file in append mode
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
FRESULT open_append (
|
||||
FIL* fp, /* [OUT] File object to create */
|
||||
const char* path /* [IN] File name to be opened */
|
||||
)
|
||||
{
|
||||
FRESULT fr;
|
||||
|
||||
/* Opens an existing file. If not exist, creates a new file. */
|
||||
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr == FR_OK) {
|
||||
/* Seek to end of the file to append data */
|
||||
fr = f_lseek(fp, f_size(fp));
|
||||
if (fr != FR_OK)
|
||||
f_close(fp);
|
||||
}
|
||||
return fr;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
FATFS fs;
|
||||
FIL fil;
|
||||
|
||||
/* Open or create a log file and ready to append */
|
||||
f_mount(&fs, "", 0);
|
||||
fr = open_append(&fil, "logfile.txt");
|
||||
if (fr != FR_OK) return 1;
|
||||
|
||||
/* Append a line */
|
||||
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
|
||||
|
||||
/* Close the file */
|
||||
f_close(&fil);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
70
Code/library/FATFS/doc/img/app2.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*------------------------------------------------------------/
|
||||
/ Remove all contents of a directory
|
||||
/ This function works regardless of _FS_RPATH.
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
|
||||
FRESULT empty_directory (
|
||||
char* path /* Working buffer filled with start directory */
|
||||
)
|
||||
{
|
||||
UINT i, j;
|
||||
FRESULT fr;
|
||||
DIR dir;
|
||||
FILINFO fno;
|
||||
|
||||
#if _USE_LFN
|
||||
fno.lfname = 0; /* Eliminate LFN output */
|
||||
#endif
|
||||
fr = f_opendir(&dir, path);
|
||||
if (fr == FR_OK) {
|
||||
for (i = 0; path[i]; i++) ;
|
||||
path[i++] = '/';
|
||||
for (;;) {
|
||||
fr = f_readdir(&dir, &fno);
|
||||
if (fr != FR_OK || !fno.fname[0]) break;
|
||||
if (fno.fname[0] == '.') continue;
|
||||
j = 0;
|
||||
do
|
||||
path[i+j] = fno.fname[j];
|
||||
while (fno.fname[j++]);
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
fr = empty_directory(path);
|
||||
if (fr != FR_OK) break;
|
||||
}
|
||||
fr = f_unlink(path);
|
||||
if (fr != FR_OK) break;
|
||||
}
|
||||
path[--i] = '\0';
|
||||
closedir(&dir);
|
||||
}
|
||||
|
||||
return fr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
FATFS fs;
|
||||
char buff[64]; /* Working buffer */
|
||||
|
||||
|
||||
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
strcpy(buff, "/"); /* Directory to be emptied */
|
||||
fr = empty_directory(buff);
|
||||
|
||||
if (fr) {
|
||||
printf("Function failed. (%u)\n", fr);
|
||||
return 1;
|
||||
} else {
|
||||
printf("All contents in the %s are successfully removed.\n", buff);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
106
Code/library/FATFS/doc/img/app3.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*----------------------------------------------------------------------/
|
||||
/ Allocate a contiguous area to the file
|
||||
/-----------------------------------------------------------------------/
|
||||
/ This function checks if the file is contiguous with desired size.
|
||||
/ If not, a block of contiguous sectors is allocated to the file.
|
||||
/ If the file has been opened without FA_WRITE flag, it only checks if
|
||||
/ the file is contiguous and returns the resulut. */
|
||||
|
||||
#if _FATFS != 29000 /* Check if R0.10a */
|
||||
#error This function may not be compatible with this revision of FatFs module.
|
||||
#endif
|
||||
|
||||
/* Declarations of FatFs internal functions accessible from applications.
|
||||
/ This is intended to be used for disk checking/fixing or dirty hacks :-) */
|
||||
DWORD clust2sect (FATFS* fs, DWORD clst);
|
||||
DWORD get_fat (FATFS* fs, DWORD clst);
|
||||
FRESULT put_fat (FATFS* fs, DWORD clst, DWORD val);
|
||||
|
||||
|
||||
DWORD allocate_contiguous_clusters ( /* Returns the first sector in LBA (0:error or not contiguous) */
|
||||
FIL* fp, /* Pointer to the open file object */
|
||||
DWORD len /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
DWORD csz, tcl, ncl, ccl, cl;
|
||||
|
||||
|
||||
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
|
||||
return 0;
|
||||
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
|
||||
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
|
||||
len = tcl * csz; /* Round-up file size to the cluster boundary */
|
||||
|
||||
/* Check if the existing cluster chain is contiguous */
|
||||
if (len == fp->fsize) {
|
||||
ncl = 0; ccl = fp->sclust;
|
||||
do {
|
||||
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
|
||||
if (cl + 1 < 3) return 0; /* Hard error? */
|
||||
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */
|
||||
ccl = cl;
|
||||
} while (++ncl < tcl);
|
||||
if (ncl == tcl) /* Is the file contiguous? */
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
}
|
||||
#if _FS_READONLY
|
||||
return 0;
|
||||
#else
|
||||
if (f_truncate(fp)) return 0; /* Remove the existing chain */
|
||||
|
||||
/* Find a free contiguous area */
|
||||
ccl = cl = 2; ncl = 0;
|
||||
do {
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */
|
||||
do { /* Skip the block of used clusters */
|
||||
cl++;
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
} while (get_fat(fp->fs, cl));
|
||||
ccl = cl; ncl = 0;
|
||||
}
|
||||
cl++; ncl++;
|
||||
} while (ncl < tcl);
|
||||
|
||||
/* Create a contiguous cluster chain */
|
||||
fp->fs->last_clust = ccl - 1;
|
||||
if (f_lseek(fp, len)) return 0;
|
||||
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
DRESULT dr;
|
||||
FATFS fs;
|
||||
FIL fil;
|
||||
DWORD org;
|
||||
|
||||
|
||||
/* Open or create a file */
|
||||
f_mount(&fs, "", 0);
|
||||
fr = f_open(&fil, "swapfile.sys", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr) return 1;
|
||||
|
||||
/* Check if the file is 64MB in size and occupies a contiguous area.
|
||||
/ If not, a contiguous area will be re-allocated to the file. */
|
||||
org = allocate_contiguous_clusters(&fil, 0x4000000);
|
||||
if (!org) {
|
||||
printf("Function failed due to any error or insufficient contiguous area.\n");
|
||||
f_close(&fil);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Now you can read/write the file with disk functions bypassing the file system layer. */
|
||||
|
||||
dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512KiB from top of the file */
|
||||
|
||||
...
|
||||
|
||||
f_close(&fil);
|
||||
return 0;
|
||||
}
|
||||
|
||||
318
Code/library/FATFS/doc/img/app4.c
Normal file
@ -0,0 +1,318 @@
|
||||
/*----------------------------------------------------------------------/
|
||||
/ Low level disk I/O module function checker
|
||||
/-----------------------------------------------------------------------/
|
||||
/ WARNING: The data on the target drive will be lost!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ff.h"
|
||||
#include "diskio.h"
|
||||
|
||||
|
||||
static
|
||||
DWORD pn (
|
||||
DWORD pns
|
||||
)
|
||||
{
|
||||
static DWORD lfsr;
|
||||
UINT n;
|
||||
|
||||
|
||||
if (pns) {
|
||||
lfsr = pns;
|
||||
for (n = 0; n < 32; n++) pn(0);
|
||||
}
|
||||
if (lfsr & 1) {
|
||||
lfsr >>= 1;
|
||||
lfsr ^= 0x80200003;
|
||||
} else {
|
||||
lfsr >>= 1;
|
||||
}
|
||||
return lfsr;
|
||||
}
|
||||
|
||||
|
||||
int test_diskio (
|
||||
BYTE pdrv, /* Physical drive number to be checked (all data on the drive will be lost) */
|
||||
UINT ncyc, /* Number of test cycles */
|
||||
DWORD* buff, /* Pointer to the working buffer */
|
||||
UINT sz_buff /* Size of the working buffer in unit of byte */
|
||||
)
|
||||
{
|
||||
UINT n, cc, ns;
|
||||
DWORD sz_drv, lba, lba2, pns = 1;
|
||||
WORD sz_sect, sz_eblk;
|
||||
BYTE *pbuff = (BYTE*)buff;
|
||||
DSTATUS ds;
|
||||
DRESULT dr;
|
||||
|
||||
|
||||
|
||||
printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff);
|
||||
|
||||
if (sz_buff < _MAX_SS + 4) {
|
||||
printf("Insufficient work area to test.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (cc = 1; cc <= ncyc; cc++) {
|
||||
printf("**** Test cycle %u of %u start ****\n", cc, ncyc);
|
||||
|
||||
/* Initialization */
|
||||
printf(" disk_initalize(%u)", pdrv);
|
||||
ds = disk_initialize(pdrv);
|
||||
if (ds & STA_NOINIT) {
|
||||
printf(" - failed.\n");
|
||||
return 2;
|
||||
} else {
|
||||
printf(" - ok.\n");
|
||||
}
|
||||
|
||||
/* Get drive size */
|
||||
printf("**** Get drive size ****\n");
|
||||
printf(" disk_ioctl(%u, GET_SECTOR_COUNT, 0x%08X)", pdrv, (UINT)&sz_drv);
|
||||
sz_drv = 0;
|
||||
dr = disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_drv);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 3;
|
||||
}
|
||||
if (sz_drv < 128) {
|
||||
printf("Failed: Insufficient drive size to test.\n");
|
||||
return 4;
|
||||
}
|
||||
printf(" Number of sectors on the drive %u is %lu.\n", pdrv, sz_drv);
|
||||
|
||||
#if _MAX_SS != _MIN_SS
|
||||
/* Get sector size */
|
||||
printf("**** Get sector size ****\n");
|
||||
printf(" disk_ioctl(%u, GET_SECTOR_SIZE, 0x%X)", pdrv, (UINT)&sz_sect);
|
||||
sz_sect = 0;
|
||||
dr = disk_ioctl(pdrv, GET_SECTOR_SIZE, &sz_sect);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 5;
|
||||
}
|
||||
printf(" Size of sector is %u bytes.\n", sz_sect);
|
||||
#else
|
||||
sz_sect = _MAX_SS;
|
||||
#endif
|
||||
|
||||
/* Get erase block size */
|
||||
printf("**** Get block size ****\n");
|
||||
printf(" disk_ioctl(%u, GET_BLOCK_SIZE, 0x%X)", pdrv, (UINT)&sz_eblk);
|
||||
sz_eblk = 0;
|
||||
dr = disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_eblk);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
}
|
||||
if (dr == RES_OK || sz_eblk >= 2) {
|
||||
printf(" Size of the erase block is %u sectors.\n", sz_eblk);
|
||||
} else {
|
||||
printf(" Size of the erase block is unknown.\n");
|
||||
}
|
||||
|
||||
/* Single sector write test */
|
||||
printf("**** Single sector write test 1 ****\n");
|
||||
lba = 0;
|
||||
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);
|
||||
dr = disk_write(pdrv, pbuff, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 6;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 7;
|
||||
}
|
||||
memset(pbuff, 0, sz_sect);
|
||||
printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);
|
||||
dr = disk_read(pdrv, pbuff, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 8;
|
||||
}
|
||||
for (n = 0, pn(pns); n < sz_sect && pbuff[n] == (BYTE)pn(0); n++) ;
|
||||
if (n == sz_sect) {
|
||||
printf(" Data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
return 10;
|
||||
}
|
||||
pns++;
|
||||
|
||||
/* Multiple sector write test */
|
||||
printf("**** Multiple sector write test ****\n");
|
||||
lba = 1; ns = sz_buff / sz_sect;
|
||||
if (ns > 4) ns = 4;
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_write(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 11;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 12;
|
||||
}
|
||||
memset(pbuff, 0, sz_sect * ns);
|
||||
printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_read(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 13;
|
||||
}
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ;
|
||||
if (n == (UINT)(sz_sect * ns)) {
|
||||
printf(" Data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
return 14;
|
||||
}
|
||||
pns++;
|
||||
|
||||
/* Single sector write test (misaligned memory address) */
|
||||
printf("**** Single sector write test 2 ****\n");
|
||||
lba = 5;
|
||||
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n+3] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+3), lba);
|
||||
dr = disk_write(pdrv, pbuff+3, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 15;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 16;
|
||||
}
|
||||
memset(pbuff+5, 0, sz_sect);
|
||||
printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+5), lba);
|
||||
dr = disk_read(pdrv, pbuff+5, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 17;
|
||||
}
|
||||
for (n = 0, pn(pns); n < sz_sect && pbuff[n+5] == (BYTE)pn(0); n++) ;
|
||||
if (n == sz_sect) {
|
||||
printf(" Data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
return 18;
|
||||
}
|
||||
pns++;
|
||||
|
||||
/* 4GB barrier test */
|
||||
printf("**** 4GB barrier test ****\n");
|
||||
if (sz_drv >= 128 + 0x80000000 / (sz_sect / 2)) {
|
||||
lba = 6; lba2 = lba + 0x80000000 / (sz_sect / 2);
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * 2); n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);
|
||||
dr = disk_write(pdrv, pbuff, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 19;
|
||||
}
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2);
|
||||
dr = disk_write(pdrv, pbuff+sz_sect, lba2, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 20;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 21;
|
||||
}
|
||||
memset(pbuff, 0, sz_sect * 2);
|
||||
printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);
|
||||
dr = disk_read(pdrv, pbuff, lba, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 22;
|
||||
}
|
||||
printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2);
|
||||
dr = disk_read(pdrv, pbuff+sz_sect, lba2, 1);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 23;
|
||||
}
|
||||
for (n = 0, pn(pns); pbuff[n] == (BYTE)pn(0) && n < (UINT)(sz_sect * 2); n++) ;
|
||||
if (n == (UINT)(sz_sect * 2)) {
|
||||
printf(" Data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
return 24;
|
||||
}
|
||||
} else {
|
||||
printf(" Test skipped.\n");
|
||||
}
|
||||
pns++;
|
||||
|
||||
printf("**** Test cycle %u of %u completed ****\n\n", cc, ncyc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int rc;
|
||||
DWORD buff[512]; /* 2048 byte working buffer */
|
||||
|
||||
/* Check function/compatibility of the physical drive #0 */
|
||||
rc = test_diskio(0, 1, buff, sizeof buff);
|
||||
if (res) {
|
||||
printf("Sorry the function/compatibility test failed.\nFatFs will not work on this disk driver.\n");
|
||||
} else {
|
||||
printf("Congratulations! The disk I/O layer works well.\n");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
BIN
Code/library/FATFS/doc/img/f1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Code/library/FATFS/doc/img/f2.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Code/library/FATFS/doc/img/f3.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
Code/library/FATFS/doc/img/f4.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
Code/library/FATFS/doc/img/f5.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Code/library/FATFS/doc/img/f6.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Code/library/FATFS/doc/img/f7.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Code/library/FATFS/doc/img/funcs.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Code/library/FATFS/doc/img/layers.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
Code/library/FATFS/doc/img/layers3.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
Code/library/FATFS/doc/img/modules.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
Code/library/FATFS/doc/img/rwtest.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
Code/library/FATFS/doc/img/rwtest2.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
Code/library/FATFS/doc/img/rwtest3.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
142
Code/library/FATFS/doc/updates.txt
Normal file
@ -0,0 +1,142 @@
|
||||
R0.10a, Jan 15,'14
|
||||
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||
Fixed f_mount() with forced mount fails when drive number is >= 1.
|
||||
Fixed f_close() invalidates the file object without volume lock.
|
||||
Fixed f_closedir() returns but the volume lock is left acquired.
|
||||
Fixed creation of an entry with LFN fails on too many SFN collisions.
|
||||
|
||||
R0.10, Oct 02,'13
|
||||
Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||
Added f_closedir().
|
||||
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||
Added forced mount feature with changes of f_mount().
|
||||
Improved behavior of volume auto detection.
|
||||
Improved write throughput of f_puts() and f_printf().
|
||||
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
|
||||
|
||||
R0.09b, Jan 24, 2013
|
||||
Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1)
|
||||
|
||||
R0.09a, Aug 27, 2012
|
||||
Fixed assertion failure due to OS/2 EA on FAT12/16.
|
||||
Changed API rejects null object pointer to avoid crash.
|
||||
Changed option name _FS_SHARE to _FS_LOCK.
|
||||
|
||||
R0.09, Sep 06, 2011
|
||||
f_mkfs() supports multiple partition to finish the multiple partition feature.
|
||||
Added f_fdisk(). (_MULTI_PARTITION = 2)
|
||||
|
||||
R0.08b, Jan 15, 2011
|
||||
Fast seek feature is also applied to f_read() and f_write().
|
||||
f_lseek() reports required table size on creating CLMP.
|
||||
Extended format syntax of f_printf().
|
||||
Ignores duplicated directory separators in given path names.
|
||||
|
||||
R0.08a, Aug 16, 2010
|
||||
Added f_getcwd(). (_FS_RPATH = 2)
|
||||
Added sector erase feature. (_USE_ERASE)
|
||||
Moved file lock semaphore table from fs object to the bss.
|
||||
Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
|
||||
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||
|
||||
R0.08, May 15, 2010
|
||||
Added a memory configuration option. (_USE_LFN)
|
||||
Added file lock feature. (_FS_SHARE)
|
||||
Added fast seek feature. (_USE_FASTSEEK)
|
||||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
R0.07e, Nov 3, 2009
|
||||
Separated out configuration options from ff.h to ffconf.h.
|
||||
Added a configuration option, _LFN_UNICODE.
|
||||
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||
Fixed name matching error on the 13 char boundary.
|
||||
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||
|
||||
R0.07c, Jun 21, 2009
|
||||
Fixed f_unlink() may return FR_OK on error.
|
||||
Fixed wrong cache control in f_lseek().
|
||||
Added relative path feature.
|
||||
Added f_chdir().
|
||||
Added f_chdrive().
|
||||
Added proper case conversion to extended characters.
|
||||
|
||||
R0.07a, Apr 14, 2009
|
||||
Separated out OS dependent code on re-entrant configuration.
|
||||
Added multiple sector size support.
|
||||
|
||||
R0.07, Apr 01, 2009
|
||||
Merged Tiny-FatFs into FatFs as a buffer configuration option.
|
||||
Added long file name support.
|
||||
Added multiple code page support.
|
||||
Added re-entrancy for multitask operation.
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
R0.06, Apr 01, 2008
|
||||
Added f_forward. (Tiny-FatFs)
|
||||
Added string functions: fgets, fputc, fputs and fprintf.
|
||||
Improved performance of f_lseek on moving to the same or following cluster.
|
||||
|
||||
R0.05a, Feb 03, 2008
|
||||
Added f_truncate.
|
||||
Added f_utime.
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read can be mistruncated.
|
||||
Fixed cached sector is left not flushed when create and close without write.
|
||||
|
||||
R0.05, Aug 26, 2007
|
||||
Changed arguments of f_read, f_write.
|
||||
Changed arguments of f_mkfs. (FatFs)
|
||||
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
|
||||
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
|
||||
|
||||
R0.04b, May 05, 2007
|
||||
Added _USE_NTFLAG option.
|
||||
Added FSInfo support.
|
||||
Fixed some problems corresponds to FAT32. (Tiny-FatFs)
|
||||
Fixed DBCS name can result FR_INVALID_NAME.
|
||||
Fixed short seek (<= csize) collapses the file object.
|
||||
|
||||
R0.04a, Apr 01, 2007
|
||||
Supported multiple partitions on a plysical drive. (FatFs)
|
||||
Added minimization level 3.
|
||||
Added a capability of extending file size to f_lseek.
|
||||
Fixed an endian sensitive code in f_mkfs. (FatFs)
|
||||
Fixed a problem corresponds to FAT32 support. (Tiny-FatFs)
|
||||
|
||||
R0.04, Feb 04, 2007
|
||||
Supported multiple drive system. (FatFs)
|
||||
Changed some APIs for multiple drive system.
|
||||
Added f_mkfs. (FatFs)
|
||||
Added _USE_FAT32 option. (Tiny-FatFs)
|
||||
|
||||
R0.03a, Dec 11, 2006
|
||||
Improved cluster scan algolithm to write files fast.
|
||||
Fixed f_mkdir creates incorrect directory on FAT32.
|
||||
|
||||
R0.03, Sep 22, 2006
|
||||
Added f_rename.
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
R0.02a, Jun 10, 2006
|
||||
Added a configuration option _FS_MINIMUM.
|
||||
|
||||
R0.02, Jun 01, 2006
|
||||
Added FAT12.
|
||||
Removed unbuffered mode.
|
||||
Fixed a problem on small (<32M) patition.
|
||||
|
||||
R0.01, Apr 29, 2006
|
||||
First release
|
||||
|
||||
R0.00, Feb 26, 2006
|
||||
Prototype (not released)
|
||||
|
||||
155
Code/library/FATFS/src/00readme.txt
Normal file
@ -0,0 +1,155 @@
|
||||
FatFs Module Source Files R0.10a (C)ChaN, 2014
|
||||
|
||||
|
||||
FILES
|
||||
|
||||
ffconf.h Configuration file for FatFs module.
|
||||
ff.h Common include file for FatFs and application module.
|
||||
ff.c FatFs module.
|
||||
diskio.h Common include file for FatFs and disk I/O module.
|
||||
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
|
||||
integer.h Integer type definitions for FatFs.
|
||||
option Optional external functions.
|
||||
|
||||
Low level disk I/O module is not included in this archive because the FatFs
|
||||
module is only a generic file system layer and not depend on any specific
|
||||
storage device. You have to provide a low level disk I/O module that written
|
||||
to control your storage device.
|
||||
|
||||
|
||||
|
||||
AGREEMENTS
|
||||
|
||||
FatFs module is an open source software to implement FAT file system to
|
||||
small embedded systems. This is a free software and is opened for education,
|
||||
research and commercial developments under license policy of following trems.
|
||||
|
||||
Copyright (C) 2014, ChaN, all right reserved.
|
||||
|
||||
* The FatFs module is a free software and there is NO WARRANTY.
|
||||
* No restriction on use. You can use, modify and redistribute it for
|
||||
personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
* Redistributions of source code must retain the above copyright notice.
|
||||
|
||||
|
||||
|
||||
REVISION HISTORY
|
||||
|
||||
Feb 26, 2006 R0.00 Prototype
|
||||
|
||||
Apr 29, 2006 R0.01 First release.
|
||||
|
||||
Jun 01, 2006 R0.02 Added FAT12.
|
||||
Removed unbuffered mode.
|
||||
Fixed a problem on small (<32M) patition.
|
||||
|
||||
Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM.
|
||||
|
||||
Sep 22, 2006 R0.03 Added f_rename.
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast.
|
||||
Fixed f_mkdir creates incorrect directory on FAT32.
|
||||
|
||||
Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs)
|
||||
Changed some APIs for multiple drive system.
|
||||
Added f_mkfs. (FatFs)
|
||||
Added _USE_FAT32 option. (Tiny-FatFs)
|
||||
|
||||
Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs)
|
||||
Fixed an endian sensitive code in f_mkfs. (FatFs)
|
||||
Added a capability of extending the file size to f_lseek.
|
||||
Added minimization level 3.
|
||||
Fixed a problem that can collapse a sector when recreate an
|
||||
existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs)
|
||||
|
||||
May 05, 2007 R0.04b Added _USE_NTFLAG option.
|
||||
Added FSInfo support.
|
||||
Fixed some problems corresponds to FAT32. (Tiny-FatFs)
|
||||
Fixed DBCS name can result FR_INVALID_NAME.
|
||||
Fixed short seek (0 < ofs <= csize) collapses the file object.
|
||||
|
||||
Aug 25, 2007 R0.05 Changed arguments of f_read, f_write.
|
||||
Changed arguments of f_mkfs. (FatFs)
|
||||
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
|
||||
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
|
||||
|
||||
Feb 03, 2008 R0.05a Added f_truncate().
|
||||
Added f_utime().
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read() can be mistruncated.
|
||||
Fixed cached sector is not flushed when create and close without write.
|
||||
|
||||
Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs)
|
||||
Added string functions: fputc(), fputs(), fprintf() and fgets().
|
||||
Improved performance of f_lseek() on move to the same or following cluster.
|
||||
|
||||
Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option.
|
||||
Added long file name support.
|
||||
Added multiple code page support.
|
||||
Added re-entrancy for multitask operation.
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg.
|
||||
Added multiple sector size support.
|
||||
|
||||
Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error.
|
||||
Fixed wrong cache control in f_lseek().
|
||||
Added relative path feature.
|
||||
Added f_chdir().
|
||||
Added f_chdrive().
|
||||
Added proper case conversion for extended characters.
|
||||
|
||||
Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h.
|
||||
Added a configuration option, _LFN_UNICODE.
|
||||
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||
Fixed name matching error on the 13 char boundary.
|
||||
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||
|
||||
May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN)
|
||||
Added file lock feature. (_FS_SHARE)
|
||||
Added fast seek feature. (_USE_FASTSEEK)
|
||||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
|
||||
Added sector erase feature. (_USE_ERASE)
|
||||
Moved file lock semaphore table from fs object to the bss.
|
||||
Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
|
||||
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||
|
||||
Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
|
||||
f_lseek() reports required table size on creating CLMP.
|
||||
Extended format syntax of f_printf function.
|
||||
Ignores duplicated directory separators in given path names.
|
||||
|
||||
Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature.
|
||||
Added f_fdisk(). (_MULTI_PARTITION = 2)
|
||||
|
||||
Aug 27,'12 R0.09a Fixed assertion failure due to OS/2 EA on FAT12/16.
|
||||
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
|
||||
Changed option name _FS_SHARE to _FS_LOCK.
|
||||
|
||||
Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL)
|
||||
|
||||
Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||
Added f_closedir().
|
||||
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||
Added forced mount feature with changes of f_mount().
|
||||
Improved behavior of volume auto detection.
|
||||
Improved write throughput of f_puts() and f_printf().
|
||||
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
|
||||
|
||||
Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||
Fixed f_mount() with forced mount fails when drive number is >= 1.
|
||||
Fixed f_close() invalidates the file object without volume lock.
|
||||
Fixed f_closedir() returns but the volume lock is left acquired.
|
||||
Fixed creation of an entry with LFN fails on too many SFN collisions.
|
||||
257
Code/library/FATFS/src/diskio.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
/* This is an example of glue functions to attach various exsisting */
|
||||
/* storage control module to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "diskio.h" /* FatFs lower layer API */
|
||||
#include "tfcard_sdio.h"
|
||||
#include "w25qxx.h"
|
||||
#include "malloc.h"
|
||||
#include "usbhost_user.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define SD_CARD 0 //SD卡,卷标为0
|
||||
#define EX_FLASH 1 //外部flash,卷标为1
|
||||
#define USB_DISK 2 //U盘,卷标为2
|
||||
|
||||
#define FLASH_SECTOR_SIZE 512
|
||||
|
||||
u16 FLASH_SECTOR_COUNT=2048*10; //W25Q1218,前10M字节给FATFS占用
|
||||
#define FLASH_BLOCK_SIZE 8 //每个BLOCK有8个扇区
|
||||
|
||||
//初始化磁盘
|
||||
DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive nmuber (0..) */
|
||||
)
|
||||
{
|
||||
u8 res=0;
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD://SD卡
|
||||
res = SD_Init();
|
||||
break;
|
||||
case EX_FLASH://外部FLASH
|
||||
W25QXX_Init();
|
||||
FLASH_SECTOR_COUNT=2048*10; //W25Q1218,前10M字节给FATFS用
|
||||
case USB_DISK://U盘
|
||||
if(USBH_UDISK_Status())return 0; //U盘连接成功,则返回1.否则返回0
|
||||
else return 1;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
if(res)return STA_NOINIT;
|
||||
else return 0; //初始化成功
|
||||
}
|
||||
|
||||
//获得磁盘状态
|
||||
DSTATUS disk_status (
|
||||
BYTE pdrv /* Physical drive nmuber (0..) */
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************
|
||||
* 名 称: DRESULT disk_read ()
|
||||
* 功 能:读扇区
|
||||
* 入口参数:drv:磁盘编号0~9
|
||||
buff:数据接收缓冲首地址
|
||||
sector:扇区地址
|
||||
count:需要读取的扇区数
|
||||
* 返回参数:
|
||||
* 说 明:移植文件系统要调用SD卡和W25Qxx的读扇区函数
|
||||
****************************************************************************/
|
||||
DRESULT disk_read (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector address (LBA) */
|
||||
UINT count /* Number of sectors to read (1..128) */
|
||||
)
|
||||
{
|
||||
u8 res=0;
|
||||
if (!count)return RES_PARERR;
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD: //SD卡
|
||||
res=SD_ReadSDisk(buff,sector,count);
|
||||
break;
|
||||
case EX_FLASH: //外部FLASH
|
||||
for(;count>0;count--)
|
||||
{
|
||||
W25QXX_Read(buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
|
||||
sector++;
|
||||
buff+=FLASH_SECTOR_SIZE;
|
||||
}
|
||||
res=0;
|
||||
break;
|
||||
case USB_DISK://U盘
|
||||
res=USBH_UDISK_Read(buff,sector,count);
|
||||
break;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
|
||||
if(res==0x00)return RES_OK;
|
||||
else return RES_ERROR;
|
||||
}
|
||||
/****************************************************************************
|
||||
* 名 称: DRESULT disk_write ()
|
||||
* 功 能:写扇区
|
||||
* 入口参数:drv:磁盘编号0~9
|
||||
buff:数据接收缓冲首地址
|
||||
sector:扇区地址
|
||||
count:需要写入的扇区数
|
||||
* 返回参数:
|
||||
* 说 明:移植文件系统要调用SD卡和W25Qxx的写扇区函数
|
||||
****************************************************************************/
|
||||
#if _USE_WRITE
|
||||
DRESULT disk_write (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector address (LBA) */
|
||||
UINT count /* Number of sectors to write (1..128) */
|
||||
)
|
||||
{
|
||||
u8 res=0;
|
||||
if (!count)return RES_PARERR;
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD://SD卡
|
||||
res=SD_WriteSDisk((u8*)buff,sector,count);
|
||||
break;
|
||||
case EX_FLASH://外部FLASH
|
||||
for(;count>0;count--)
|
||||
{
|
||||
W25QXX_SectorWrite((u8*)buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
|
||||
sector++;
|
||||
buff+=FLASH_SECTOR_SIZE;
|
||||
}
|
||||
res=0;
|
||||
break;
|
||||
case USB_DISK://U盘
|
||||
res=USBH_UDISK_Write((u8*)buff,sector,count);
|
||||
break;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
|
||||
if(res == 0x00)return RES_OK;
|
||||
else return RES_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 名 称: DRESULT disk_ioctl ()
|
||||
* 功 能:其他表参数的获得
|
||||
* 入口参数:drv:磁盘编号0~9
|
||||
ctrl:控制代码
|
||||
buff:发送/接收缓冲区指针
|
||||
* 返回参数:
|
||||
* 说 明:
|
||||
****************************************************************************/
|
||||
#if _USE_IOCTL
|
||||
DRESULT disk_ioctl (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE cmd, /* Control code */
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
if(pdrv==SD_CARD)//SD卡
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
*(DWORD*)buff = 512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
*(WORD*)buff = SDCardInfo.CardBlockSize;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD*)buff = SDCardInfo.CardCapacity/512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
}else if(pdrv==EX_FLASH) //外部FLASH
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
*(WORD*)buff = FLASH_SECTOR_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
*(WORD*)buff = FLASH_BLOCK_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD*)buff = FLASH_SECTOR_COUNT;
|
||||
res = RES_OK;
|
||||
break;
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(pdrv==USB_DISK) //U盘
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
*(WORD*)buff=512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
*(WORD*)buff=512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD*)buff=USBH_MSC_Param.MSCapacity;
|
||||
res = RES_OK;
|
||||
break;
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else res=RES_ERROR;//其他的不支持
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
//获得时间
|
||||
//User defined function to give a current time to fatfs module */
|
||||
//31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
//15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
DWORD get_fattime (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//动态分配内存
|
||||
void *ff_memalloc (UINT size)
|
||||
{
|
||||
return (void*)Mem_malloc(INSRAM,size);
|
||||
}
|
||||
//释放内存
|
||||
void ff_memfree (void* mf)
|
||||
{
|
||||
Mem_free(INSRAM,mf);
|
||||
}
|
||||
80
Code/library/FATFS/src/diskio.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2013 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
|
||||
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
|
||||
|
||||
/* Generic command (not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
#define MMC_GET_TYPE 10 /* Get card type */
|
||||
#define MMC_GET_CSD 11 /* Get CSD */
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
4585
Code/library/FATFS/src/ff.c
Normal file
342
Code/library/FATFS/src/ff.h
Normal file
@ -0,0 +1,342 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.10a (C)ChaN, 2014
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||
/ This is a free software that opened for education, research and commercial
|
||||
/ developments under license policy of following terms.
|
||||
/
|
||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 29000 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if _FATFS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
||||
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
||||
|
||||
#else /* Single partition configuration */
|
||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#error _LFN_UNICODE must be 0 in non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#endif
|
||||
|
||||
#else /* ANSI/OEM string */
|
||||
#ifndef _INC_TCHAR
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter */
|
||||
DWORD dsect; /* Current data sector of fpter */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File data read/write buffer */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File status structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive cannot work */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#define FA__DIRTY 0x40
|
||||
#endif
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Fast seek feature */
|
||||
#define CREATE_LINKMAP 0xFFFFFFFF
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
222
Code/library/FATFS/src/ffconf.h
Normal file
@ -0,0 +1,222 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.10a (C)ChaN, 2014
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 29000 /* Revision ID */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
|
||||
/* When _FS_TINY is set to 1, it reduces memory consumption _MAX_SS bytes each
|
||||
/ file object. For file data transfer, FatFs uses the common sector buffer in
|
||||
/ the file system object (FATFS) instead of private sector buffer eliminated
|
||||
/ from the file object (FIL). */
|
||||
|
||||
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(),
|
||||
/ f_rename(), f_truncate() and useless f_getfree(). */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
|
||||
|
||||
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_mkfs() function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 1 /* 0:Disable or 1:Enable */
|
||||
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
|
||||
|
||||
|
||||
#define _USE_LABEL 1 /* 0:Disable or 1:Enable */
|
||||
/* To enable volume label functions, set _USE_LAVEL to 1 */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_forward() function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 936 //采用中文GBK编码
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
/ 1250 - Central Europe (Windows)
|
||||
/ 1251 - Cyrillic (Windows)
|
||||
/ 1252 - Latin 1 (Windows)
|
||||
/ 1253 - Greek (Windows)
|
||||
/ 1254 - Turkish (Windows)
|
||||
/ 1255 - Hebrew (Windows)
|
||||
/ 1256 - Arabic (Windows)
|
||||
/ 1257 - Baltic (Windows)
|
||||
/ 1258 - Vietnam (OEM, Windows)
|
||||
/ 437 - U.S. (OEM)
|
||||
/ 720 - Arabic (OEM)
|
||||
/ 737 - Greek (OEM)
|
||||
/ 775 - Baltic (OEM)
|
||||
/ 850 - Multilingual Latin 1 (OEM)
|
||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
||||
/ 852 - Latin 2 (OEM)
|
||||
/ 855 - Cyrillic (OEM)
|
||||
/ 866 - Russian (OEM)
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII (Valid for only non-LFN cfg.) */
|
||||
|
||||
|
||||
#define _USE_LFN 3 /* 0 to 3 设置为1,支持长文件名,并采用动态内存*/
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper()
|
||||
/ function must be added to the project.
|
||||
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When use stack for the
|
||||
/ working buffer, take care on stack overflow. When use heap memory for the working
|
||||
/ buffer, memory management functions, ff_memalloc() and ff_memfree(), must be added
|
||||
/ to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
|
||||
/* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN
|
||||
/ feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O
|
||||
/ functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
|
||||
/* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character
|
||||
/ encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(),
|
||||
/ f_puts and f_printf(). This option has no effect when Unicode API is not enabled. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0 /* 0 to 2 */
|
||||
/* The _FS_RPATH option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that output of the f_readdir() fnction is affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 3
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* When _STR_VOLUME_ID is set to 1, also pre-defined string can be used as drive number
|
||||
/ in the path name. _VOLUME_STRS defines the drive ID strings for each logical drives.
|
||||
/ Number of items must be equal to _VOLUMES. Valid characters for the drive ID strings
|
||||
/ are: 0-9 and A-Z. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
|
||||
/* By default(0), each logical drive number is bound to the same physical drive number
|
||||
/ and only a FAT volume found on the physical drive is mounted. When it is set to 1,
|
||||
/ each logical drive number is bound to arbitrary drive/partition listed in VolToPart[].
|
||||
*/
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the sector size to be supported. (512, 1024, 2048 or 4096)
|
||||
/ Always set both 512 for most systems, all memory card and hard disk. But a larger
|
||||
/ value may be required for on-board flash memory and some type of optical media.
|
||||
/ When _MIN_SS != _MAX_SS, FatFs is configured to multiple sector size and
|
||||
/ GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable sector erase feature, set _USE_ERASE to 1. Also CTRL_ERASE_SECTOR command
|
||||
/ should be added to the disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0 /* 0 to 3 */
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the last allocated cluster number as bit 0.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _WORD_ACCESS 0 /* 0 or 1 */
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed for all instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance
|
||||
/ and reduce code size.
|
||||
*/
|
||||
|
||||
|
||||
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
|
||||
/* To enable file lock control feature, set _FS_LOCK to 1 or greater.
|
||||
/ The value defines how many files/sub-directories can be opened simultaneously.
|
||||
/ This feature consumes _FS_LOCK * 12 bytes of bss area. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _SYNC_t HANDLE /* O/S dependent sync object type. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
||||
/*#include <windows.h>*/
|
||||
|
||||
/* A header file that defines sync object types on the O/S, such as windows.h,
|
||||
/ ucos_ii.h and semphr.h, should be included here when enable this option.
|
||||
/ The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function must be added to the project.
|
||||
*/
|
||||
|
||||
|
||||
#endif /* _FFCONFIG */
|
||||
33
Code/library/FATFS/src/integer.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* This type MUST be 8 bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types MUST be 16 bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types MUST be 16 bit or 32 bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types MUST be 32 bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
3798
Code/library/FATFS/src/option/cc932.c
Normal file
10973
Code/library/FATFS/src/option/cc936.c
Normal file
8603
Code/library/FATFS/src/option/cc949.c
Normal file
6829
Code/library/FATFS/src/option/cc950.c
Normal file
540
Code/library/FATFS/src/option/ccsbcs.c
Normal file
@ -0,0 +1,540 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Unicode - Local code bidirectional converter (C)ChaN, 2012 */
|
||||
/* (SBCS code pages) */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* 437 U.S. (OEM)
|
||||
/ 720 Arabic (OEM)
|
||||
/ 1256 Arabic (Windows)
|
||||
/ 737 Greek (OEM)
|
||||
/ 1253 Greek (Windows)
|
||||
/ 1250 Central Europe (Windows)
|
||||
/ 775 Baltic (OEM)
|
||||
/ 1257 Baltic (Windows)
|
||||
/ 850 Multilingual Latin 1 (OEM)
|
||||
/ 852 Latin 2 (OEM)
|
||||
/ 1252 Latin 1 (Windows)
|
||||
/ 855 Cyrillic (OEM)
|
||||
/ 1251 Cyrillic (Windows)
|
||||
/ 866 Russian (OEM)
|
||||
/ 857 Turkish (OEM)
|
||||
/ 1254 Turkish (Windows)
|
||||
/ 858 Multilingual Latin 1 + Euro (OEM)
|
||||
/ 862 Hebrew (OEM)
|
||||
/ 1255 Hebrew (Windows)
|
||||
/ 874 Thai (OEM, Windows)
|
||||
/ 1258 Vietnam (OEM, Windows)
|
||||
*/
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
|
||||
#if _CODE_PAGE == 437
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 720
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
|
||||
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
|
||||
0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
|
||||
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
||||
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642,
|
||||
0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
|
||||
0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 737
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
|
||||
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
|
||||
0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
|
||||
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
|
||||
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
|
||||
0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
|
||||
0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
|
||||
0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
|
||||
0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 775
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
|
||||
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
|
||||
0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
|
||||
0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
|
||||
0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
|
||||
0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
|
||||
0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
|
||||
0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
|
||||
0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
|
||||
0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
|
||||
0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
|
||||
0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 850
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
|
||||
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 852
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
|
||||
0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
|
||||
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
|
||||
0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
|
||||
0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
|
||||
0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
|
||||
0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
|
||||
0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
|
||||
0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 855
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
|
||||
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
|
||||
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
|
||||
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
|
||||
0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
|
||||
0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
|
||||
0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
|
||||
0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
|
||||
0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
|
||||
0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
|
||||
0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
|
||||
0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
|
||||
0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 857
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000,
|
||||
0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 858
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP858(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x2550, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
|
||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00C6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
|
||||
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 862
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
|
||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
|
||||
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
|
||||
0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 866
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
||||
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 874
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP874(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
|
||||
0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
|
||||
0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
|
||||
0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
|
||||
0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
|
||||
0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
|
||||
0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
|
||||
0x0E38, 0x0E39, 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F,
|
||||
0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
|
||||
0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
|
||||
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
|
||||
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1250
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1250(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
|
||||
0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
|
||||
0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
|
||||
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
|
||||
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
|
||||
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
|
||||
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
|
||||
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
|
||||
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
|
||||
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
|
||||
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1251
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1251(0x80-0xFF) to Unicode conversion table */
|
||||
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
|
||||
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x2111, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
|
||||
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
|
||||
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
|
||||
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1252
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1252(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x017E, 0x0178,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1253
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1253(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0000, 0x2039, 0x000C, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
|
||||
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
|
||||
0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
|
||||
0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
|
||||
0x03A8, 0x03A9, 0x03AA, 0x03AD, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
|
||||
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
|
||||
0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
|
||||
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
|
||||
0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1254
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1254(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x210A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00BD, 0x00DC, 0x0130, 0x015E, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1255
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1255(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
|
||||
0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
|
||||
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
|
||||
0x05F4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
|
||||
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
|
||||
0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E, 0x200F, 0x0000
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1256
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1256(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
|
||||
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
|
||||
0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
|
||||
0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
|
||||
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
||||
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
|
||||
0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0640, 0x0642, 0x0643,
|
||||
0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
|
||||
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
|
||||
0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2
|
||||
}
|
||||
|
||||
#elif _CODE_PAGE == 1257
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1257(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000,
|
||||
0x00A0, 0x0000, 0x00A2, 0x00A3, 0x00A4, 0x0000, 0x00A6, 0x00A7,
|
||||
0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
|
||||
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
|
||||
0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
|
||||
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
|
||||
0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
|
||||
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
|
||||
0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
|
||||
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
|
||||
0x0173, 0x014E, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1258
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0000, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !_TBLDEF || !_USE_LFN
|
||||
#error This file is not needed in current configuration. Remove from the project.
|
||||
#endif
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted character, Returns zero on error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
{
|
||||
WCHAR c;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
c = chr;
|
||||
|
||||
} else {
|
||||
if (dir) { /* OEMCP to Unicode */
|
||||
c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80];
|
||||
|
||||
} else { /* Unicode to OEMCP */
|
||||
for (c = 0; c < 0x80; c++) {
|
||||
if (chr == Tbl[c]) break;
|
||||
}
|
||||
c = (c + 0x80) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
|
||||
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
|
||||
|
||||
return tbl_lower[i] ? tbl_upper[i] : chr;
|
||||
}
|
||||
153
Code/library/FATFS/src/option/syscall.c
Normal file
@ -0,0 +1,153 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample code of OS dependent controls for FatFs */
|
||||
/* (C)ChaN, 2012 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h> /* ANSI memory controls */
|
||||
#include <malloc.h> /* ANSI memory controls */
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
|
||||
#if _FS_REENTRANT
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called by f_mount() function to create a new
|
||||
/ synchronization object, such as semaphore and mutex. When a 0 is
|
||||
/ returned, the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any error */
|
||||
BYTE vol, /* Corresponding logical drive being processed */
|
||||
_SYNC_t* sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
||||
ret = (int)(*sobj != INVALID_HANDLE_VALUE);
|
||||
|
||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created semaphore) */
|
||||
// ret = 1;
|
||||
|
||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
||||
// ret = (int)(*sobj != NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount() function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj() function. When a 0 is
|
||||
/ returned, the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */
|
||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
ret = CloseHandle(sobj); /* Win32 */
|
||||
|
||||
// ret = 1; /* uITRON (nothing to do) */
|
||||
|
||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// xSemaphoreDelete(sobj); /* FreeRTOS */
|
||||
// ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on entering file functions to lock the volume.
|
||||
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
|
||||
_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
||||
|
||||
// ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */
|
||||
|
||||
// OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leaving file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_rel_grant (
|
||||
_SYNC_t sobj /* Sync object to be signaled */
|
||||
)
|
||||
{
|
||||
ReleaseMutex(sobj); /* Win32 */
|
||||
|
||||
// sig_sem(sobj); /* uITRON */
|
||||
|
||||
// OSMutexPost(sobj); /* uC/OS-II */
|
||||
|
||||
// xSemaphoreGive(sobj); /* FreeRTOS */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
||||
*/
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
return malloc(msize);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Free a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free */
|
||||
)
|
||||
{
|
||||
free(mblock);
|
||||
}
|
||||
|
||||
#endif
|
||||
17
Code/library/FATFS/src/option/unicode.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "../ff.h"
|
||||
|
||||
#if _USE_LFN != 0
|
||||
|
||||
#if _CODE_PAGE == 932
|
||||
#include "cc932.c"
|
||||
#elif _CODE_PAGE == 936
|
||||
#include "cc936.c"
|
||||
#elif _CODE_PAGE == 949
|
||||
#include "cc949.c"
|
||||
#elif _CODE_PAGE == 950
|
||||
#include "cc950.c"
|
||||
#else
|
||||
#include "ccsbcs.c"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -36,17 +36,17 @@ static uint8_t mw_get_led1_state(void)
|
||||
/* led2 基础函数包 */
|
||||
static void mw_led2_on(void)
|
||||
{
|
||||
bsp_led_on(LED2);
|
||||
// bsp_led_on(LED2);
|
||||
}
|
||||
static void mw_led2_off(void)
|
||||
{
|
||||
bsp_led_off(LED2);
|
||||
// bsp_led_off(LED2);
|
||||
}
|
||||
static uint8_t mw_get_led2_state(void)
|
||||
{
|
||||
uint8_t retVal = 0;
|
||||
|
||||
retVal = bsp_get_led_ttlState(LED2);
|
||||
// retVal = bsp_get_led_ttlState(LED2);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@ -85,13 +85,13 @@ void mw_led_drv_init(void)
|
||||
led_drv_buf[LED1].off = mw_led1_off;
|
||||
led_drv_buf[LED1].state = mw_get_led1_state;
|
||||
led_drv_buf[LED1].changeBrightness = 0;
|
||||
/* led2 installation */
|
||||
led_drv_buf[LED2].led_drv = LED2;
|
||||
led_drv_buf[LED2].init = bsp_led2_init;
|
||||
led_drv_buf[LED2].on = mw_led2_on;
|
||||
led_drv_buf[LED2].off = mw_led2_off;
|
||||
led_drv_buf[LED2].state = mw_get_led2_state;
|
||||
led_drv_buf[LED2].changeBrightness = 0;
|
||||
// /* led2 installation */
|
||||
// led_drv_buf[LED2].led_drv = LED2;
|
||||
// led_drv_buf[LED2].init = bsp_led2_init;
|
||||
// led_drv_buf[LED2].on = mw_led2_on;
|
||||
// led_drv_buf[LED2].off = mw_led2_off;
|
||||
// led_drv_buf[LED2].state = mw_get_led2_state;
|
||||
// led_drv_buf[LED2].changeBrightness = 0;
|
||||
/* RGB_RED installation */
|
||||
led_drv_buf[RGB_RED].led_drv = RGB_RED;
|
||||
led_drv_buf[RGB_RED].init = bsp_RGB_RedInit;
|
||||
|
||||
@ -15,19 +15,19 @@ void mw_SetMotorSpeed_Left(int8_t Speed)
|
||||
{
|
||||
bsp_AIN1_ON();
|
||||
bsp_AIN2_OFF();
|
||||
bsp_changeRightMotorSpeed(Speed);
|
||||
bsp_changeLeftMotorSpeed(Speed);
|
||||
}
|
||||
else if(Speed==0)
|
||||
{
|
||||
bsp_AIN1_ON();
|
||||
bsp_AIN2_ON();
|
||||
bsp_changeRightMotorSpeed(Speed);
|
||||
bsp_changeLeftMotorSpeed(Speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsp_AIN1_OFF();
|
||||
bsp_AIN2_ON();
|
||||
bsp_changeRightMotorSpeed(-Speed);
|
||||
bsp_changeLeftMotorSpeed(-Speed);
|
||||
}
|
||||
}
|
||||
/*************************************************************************************
|
||||
@ -43,19 +43,19 @@ void mw_SetMotorSpeed_Right(int8_t Speed)
|
||||
{
|
||||
bsp_BIN1_ON();
|
||||
bsp_BIN2_OFF();
|
||||
bsp_changeLeftMotorSpeed(Speed);
|
||||
bsp_changeRightMotorSpeed(Speed);
|
||||
}
|
||||
else if(Speed==0)
|
||||
{
|
||||
bsp_BIN1_ON();
|
||||
bsp_BIN2_ON();
|
||||
bsp_changeLeftMotorSpeed(Speed);
|
||||
bsp_changeRightMotorSpeed(Speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsp_BIN1_OFF();
|
||||
bsp_BIN2_ON();
|
||||
bsp_changeLeftMotorSpeed(-Speed);
|
||||
bsp_changeRightMotorSpeed(-Speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
343
Code/middleware/Oled_096/OLED.c
Normal file
@ -0,0 +1,343 @@
|
||||
#include "stm32f10x.h"
|
||||
#include "OLED_Font.h"
|
||||
|
||||
|
||||
#define OLED_SCL_GPIO_PORT (GPIOB)
|
||||
#define OLED_SCL_GPIO_PIN (GPIO_Pin_3)
|
||||
#define OLED_SCL_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
|
||||
#define OLED_SDA_GPIO_PORT (GPIOB)
|
||||
#define OLED_SDA_GPIO_PIN (GPIO_Pin_4)
|
||||
#define OLED_SDA_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
|
||||
|
||||
/*引脚配置*/
|
||||
#define OLED_W_SCL(x) GPIO_WriteBit(OLED_SCL_GPIO_PORT, OLED_SCL_GPIO_PIN, (BitAction)(x))
|
||||
#define OLED_W_SDA(x) GPIO_WriteBit(OLED_SDA_GPIO_PORT, OLED_SDA_GPIO_PIN, (BitAction)(x))
|
||||
|
||||
/*引脚初始化*/
|
||||
void OLED_I2C_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
// 开启 AFIO 时钟(必须)
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
||||
|
||||
// 禁用 JTAG 功能,保留 SWD 调试(PA13/PA14 仍可用)
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||
|
||||
|
||||
RCC_APB2PeriphClockCmd(OLED_SCL_GPIO_RCC, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(OLED_SDA_GPIO_RCC, ENABLE);
|
||||
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_SCL_GPIO_PIN;
|
||||
GPIO_Init(OLED_SCL_GPIO_PORT, &GPIO_InitStructure);
|
||||
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = OLED_SDA_GPIO_PIN;
|
||||
GPIO_Init(OLED_SDA_GPIO_PORT, &GPIO_InitStructure);
|
||||
|
||||
OLED_W_SCL(1);
|
||||
OLED_W_SDA(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C开始
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_I2C_Start(void)
|
||||
{
|
||||
OLED_W_SDA(1);
|
||||
OLED_W_SCL(1);
|
||||
OLED_W_SDA(0);
|
||||
OLED_W_SCL(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C停止
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_I2C_Stop(void)
|
||||
{
|
||||
OLED_W_SDA(0);
|
||||
OLED_W_SCL(1);
|
||||
OLED_W_SDA(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C发送一个字节
|
||||
* @param Byte 要发送的一个字节
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_I2C_SendByte(uint8_t Byte)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
OLED_W_SDA(!!(Byte & (0x80 >> i)));
|
||||
OLED_W_SCL(1);
|
||||
OLED_W_SCL(0);
|
||||
}
|
||||
OLED_W_SCL(1); //额外的一个时钟,不处理应答信号
|
||||
OLED_W_SCL(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED写命令
|
||||
* @param Command 要写入的命令
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_WriteCommand(uint8_t Command)
|
||||
{
|
||||
OLED_I2C_Start();
|
||||
OLED_I2C_SendByte(0x78); //从机地址
|
||||
OLED_I2C_SendByte(0x00); //写命令
|
||||
OLED_I2C_SendByte(Command);
|
||||
OLED_I2C_Stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED写数据
|
||||
* @param Data 要写入的数据
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_WriteData(uint8_t Data)
|
||||
{
|
||||
OLED_I2C_Start();
|
||||
OLED_I2C_SendByte(0x78); //从机地址
|
||||
OLED_I2C_SendByte(0x40); //写数据
|
||||
OLED_I2C_SendByte(Data);
|
||||
OLED_I2C_Stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED设置光标位置
|
||||
* @param Y 以左上角为原点,向下方向的坐标,范围:0~7
|
||||
* @param X 以左上角为原点,向右方向的坐标,范围:0~127
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_SetCursor(uint8_t Y, uint8_t X)
|
||||
{
|
||||
OLED_WriteCommand(0xB0 | Y); //设置Y位置
|
||||
OLED_WriteCommand(0x10 | ((X & 0xF0) >> 4)); //设置X位置高4位
|
||||
OLED_WriteCommand(0x00 | (X & 0x0F)); //设置X位置低4位
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED清屏
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_Clear(void)
|
||||
{
|
||||
uint8_t i, j;
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
OLED_SetCursor(j, 0);
|
||||
for(i = 0; i < 128; i++)
|
||||
{
|
||||
OLED_WriteData(0x00);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示一个字符
|
||||
* @param Line 行位置,范围:1~4
|
||||
* @param Column 列位置,范围:1~16
|
||||
* @param Char 要显示的一个字符,范围:ASCII可见字符
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char)
|
||||
{
|
||||
uint8_t i;
|
||||
OLED_SetCursor((Line - 1) * 2, (Column - 1) * 8); //设置光标位置在上半部分
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
OLED_WriteData(OLED_F8x16[Char - ' '][i]); //显示上半部分内容
|
||||
}
|
||||
OLED_SetCursor((Line - 1) * 2 + 1, (Column - 1) * 8); //设置光标位置在下半部分
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
OLED_WriteData(OLED_F8x16[Char - ' '][i + 8]); //显示下半部分内容
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示字符串
|
||||
* @param Line 起始行位置,范围:1~4
|
||||
* @param Column 起始列位置,范围:1~16
|
||||
* @param String 要显示的字符串,范围:ASCII可见字符
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowString(uint8_t Line, uint8_t Column, char *String)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; String[i] != '\0'; i++)
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i, String[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED次方函数
|
||||
* @retval 返回值等于X的Y次方
|
||||
*/
|
||||
uint32_t OLED_Pow(uint32_t X, uint32_t Y)
|
||||
{
|
||||
uint32_t Result = 1;
|
||||
while (Y--)
|
||||
{
|
||||
Result *= X;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示数字(十进制,正数)
|
||||
* @param Line 起始行位置,范围:1~4
|
||||
* @param Column 起始列位置,范围:1~16
|
||||
* @param Number 要显示的数字,范围:0~4294967295
|
||||
* @param Length 要显示数字的长度,范围:1~10
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i, Number / OLED_Pow(10, Length - i - 1) % 10 + '0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示数字(十进制,带符号数)
|
||||
* @param Line 起始行位置,范围:1~4
|
||||
* @param Column 起始列位置,范围:1~16
|
||||
* @param Number 要显示的数字,范围:-2147483648~2147483647
|
||||
* @param Length 要显示数字的长度,范围:1~10
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
uint32_t Number1;
|
||||
if (Number >= 0)
|
||||
{
|
||||
OLED_ShowChar(Line, Column, '+');
|
||||
Number1 = Number;
|
||||
}
|
||||
else
|
||||
{
|
||||
OLED_ShowChar(Line, Column, '-');
|
||||
Number1 = -Number;
|
||||
}
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i + 1, Number1 / OLED_Pow(10, Length - i - 1) % 10 + '0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示数字(十六进制,正数)
|
||||
* @param Line 起始行位置,范围:1~4
|
||||
* @param Column 起始列位置,范围:1~16
|
||||
* @param Number 要显示的数字,范围:0~0xFFFFFFFF
|
||||
* @param Length 要显示数字的长度,范围:1~8
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i, SingleNumber;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
SingleNumber = Number / OLED_Pow(16, Length - i - 1) % 16;
|
||||
if (SingleNumber < 10)
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i, SingleNumber + '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i, SingleNumber - 10 + 'A');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED显示数字(二进制,正数)
|
||||
* @param Line 起始行位置,范围:1~4
|
||||
* @param Column 起始列位置,范围:1~16
|
||||
* @param Number 要显示的数字,范围:0~1111 1111 1111 1111
|
||||
* @param Length 要显示数字的长度,范围:1~16
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
OLED_ShowChar(Line, Column + i, Number / OLED_Pow(2, Length - i - 1) % 2 + '0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief OLED初始化
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void OLED_Init(void)
|
||||
{
|
||||
uint32_t i, j;
|
||||
|
||||
for (i = 0; i < 1000; i++) //上电延时
|
||||
{
|
||||
for (j = 0; j < 1000; j++);
|
||||
}
|
||||
|
||||
OLED_I2C_Init(); //端口初始化
|
||||
|
||||
OLED_WriteCommand(0xAE); //关闭显示
|
||||
|
||||
OLED_WriteCommand(0xD5); //设置显示时钟分频比/振荡器频率
|
||||
OLED_WriteCommand(0x80);
|
||||
|
||||
OLED_WriteCommand(0xA8); //设置多路复用率
|
||||
OLED_WriteCommand(0x3F);
|
||||
|
||||
OLED_WriteCommand(0xD3); //设置显示偏移
|
||||
OLED_WriteCommand(0x00);
|
||||
|
||||
OLED_WriteCommand(0x40); //设置显示开始行
|
||||
|
||||
OLED_WriteCommand(0xA1); //设置左右方向,0xA1正常 0xA0左右反置
|
||||
|
||||
OLED_WriteCommand(0xC8); //设置上下方向,0xC8正常 0xC0上下反置
|
||||
|
||||
OLED_WriteCommand(0xDA); //设置COM引脚硬件配置
|
||||
OLED_WriteCommand(0x12);
|
||||
|
||||
OLED_WriteCommand(0x81); //设置对比度控制
|
||||
OLED_WriteCommand(0xCF);
|
||||
|
||||
OLED_WriteCommand(0xD9); //设置预充电周期
|
||||
OLED_WriteCommand(0xF1);
|
||||
|
||||
OLED_WriteCommand(0xDB); //设置VCOMH取消选择级别
|
||||
OLED_WriteCommand(0x30);
|
||||
|
||||
OLED_WriteCommand(0xA4); //设置整个显示打开/关闭
|
||||
|
||||
OLED_WriteCommand(0xA6); //设置正常/倒转显示
|
||||
|
||||
OLED_WriteCommand(0x8D); //设置充电泵
|
||||
OLED_WriteCommand(0x14);
|
||||
|
||||
OLED_WriteCommand(0xAF); //开启显示
|
||||
|
||||
OLED_Clear(); //OLED清屏
|
||||
}
|
||||
15
Code/middleware/Oled_096/OLED.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __OLED_H
|
||||
#define __OLED_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void OLED_Init(void);
|
||||
void OLED_Clear(void);
|
||||
void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char);
|
||||
void OLED_ShowString(uint8_t Line, uint8_t Column, char *String);
|
||||
void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
|
||||
void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length);
|
||||
void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
|
||||
void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
|
||||
|
||||
#endif
|
||||
293
Code/middleware/Oled_096/OLED_Font.h
Normal file
@ -0,0 +1,293 @@
|
||||
#ifndef __OLED_FONT_H
|
||||
#define __OLED_FONT_H
|
||||
|
||||
/*OLED字模库,宽8像素,高16像素*/
|
||||
const uint8_t OLED_F8x16[][16]=
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
|
||||
|
||||
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
|
||||
|
||||
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
|
||||
0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
|
||||
|
||||
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
|
||||
0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
|
||||
|
||||
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
|
||||
0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
|
||||
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
|
||||
0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
|
||||
|
||||
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
|
||||
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
|
||||
0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
|
||||
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
|
||||
0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
|
||||
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
|
||||
0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
|
||||
|
||||
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
|
||||
|
||||
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
|
||||
0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
|
||||
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
|
||||
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
|
||||
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
|
||||
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
|
||||
0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
|
||||
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
|
||||
0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
|
||||
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
|
||||
0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
|
||||
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
|
||||
0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
|
||||
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
|
||||
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
|
||||
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
|
||||
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
|
||||
|
||||
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
|
||||
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,
|
||||
0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
|
||||
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
|
||||
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
|
||||
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
|
||||
|
||||
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
|
||||
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,
|
||||
0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
|
||||
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
|
||||
0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
|
||||
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
|
||||
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,
|
||||
0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
|
||||
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
|
||||
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
|
||||
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
|
||||
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,
|
||||
0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
|
||||
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
|
||||
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,
|
||||
0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
|
||||
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,
|
||||
0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
|
||||
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,
|
||||
0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
|
||||
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
|
||||
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
|
||||
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
|
||||
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
|
||||
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
|
||||
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,
|
||||
0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
|
||||
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
|
||||
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,
|
||||
0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
|
||||
|
||||
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,
|
||||
0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
|
||||
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,
|
||||
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
|
||||
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
|
||||
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
|
||||
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
|
||||
0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
|
||||
|
||||
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
|
||||
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
|
||||
|
||||
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
|
||||
|
||||
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
|
||||
|
||||
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
|
||||
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
|
||||
|
||||
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
|
||||
|
||||
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
|
||||
|
||||
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
|
||||
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
|
||||
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,
|
||||
0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
|
||||
|
||||
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
|
||||
|
||||
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
|
||||
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
|
||||
|
||||
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
|
||||
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
|
||||
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
|
||||
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
|
||||
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
|
||||
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
|
||||
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
|
||||
|
||||
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,
|
||||
0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
|
||||
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
|
||||
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
|
||||
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
|
||||
|
||||
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
|
||||
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
|
||||
|
||||
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
|
||||
|
||||
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
|
||||
};
|
||||
|
||||
#endif
|
||||
134
Code/middleware/SPI_Flash/MySPI.c
Normal file
@ -0,0 +1,134 @@
|
||||
#include "stm32f10x.h" // Device header
|
||||
|
||||
#define SPIFLASH_PERIPH_TYPE (SPI2)
|
||||
#define SPIFLASH_PERIPH_CLOCK (RCC_APB1Periph_SPI2)
|
||||
|
||||
#define SPIFLASH_NSS_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
#define SPIFLASH_NSS_GPIO_PORT (GPIOB)
|
||||
#define SPIFLASH_NSS_GPIO_PIN (GPIO_Pin_12)
|
||||
|
||||
#define SPIFLASH_SCK_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
#define SPIFLASH_SCK_GPIO_PORT (GPIOB)
|
||||
#define SPIFLASH_SCK_GPIO_PIN (GPIO_Pin_13)
|
||||
|
||||
#define SPIFLASH_MISO_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
#define SPIFLASH_MISO_GPIO_PORT (GPIOB)
|
||||
#define SPIFLASH_MISO_GPIO_PIN (GPIO_Pin_14)
|
||||
|
||||
#define SPIFLASH_MOSI_GPIO_RCC (RCC_APB2Periph_GPIOB)
|
||||
#define SPIFLASH_MOSI_GPIO_PORT (GPIOB)
|
||||
#define SPIFLASH_MOSI_GPIO_PIN (GPIO_Pin_15)
|
||||
|
||||
|
||||
/**
|
||||
* 函 数:SPI写SS引脚电平,SS仍由软件模拟
|
||||
* 参 数:BitValue 协议层传入的当前需要写入SS的电平,范围0~1
|
||||
* 返 回 值:无
|
||||
* 注意事项:此函数需要用户实现内容,当BitValue为0时,需要置SS为低电平,当BitValue为1时,需要置SS为高电平
|
||||
*/
|
||||
void MySPI_W_SS(uint8_t BitValue)
|
||||
{
|
||||
GPIO_WriteBit(SPIFLASH_NSS_GPIO_PORT, SPIFLASH_NSS_GPIO_PIN, (BitAction)BitValue); //根据BitValue,设置SS引脚的电平
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:SPI初始化
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void MySPI_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
SPI_InitTypeDef SPI_InitStructure; //定义结构体变量
|
||||
/*开启时钟*/
|
||||
RCC_APB2PeriphClockCmd(SPIFLASH_NSS_GPIO_RCC, ENABLE); //开启GPIOA的时钟
|
||||
RCC_APB2PeriphClockCmd(SPIFLASH_SCK_GPIO_RCC, ENABLE); //开启GPIOA的时钟
|
||||
RCC_APB2PeriphClockCmd(SPIFLASH_MISO_GPIO_RCC, ENABLE); //开启GPIOA的时钟
|
||||
RCC_APB2PeriphClockCmd(SPIFLASH_MOSI_GPIO_RCC, ENABLE); //开启GPIOA的时钟
|
||||
|
||||
if(SPIFLASH_PERIPH_TYPE == SPI1)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(SPIFLASH_PERIPH_CLOCK, ENABLE); //开启SPI1的时钟
|
||||
}
|
||||
else
|
||||
{
|
||||
RCC_APB1PeriphClockCmd(SPIFLASH_PERIPH_CLOCK, ENABLE);
|
||||
}
|
||||
|
||||
/*GPIO初始化*/
|
||||
// NSS
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = SPIFLASH_NSS_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(SPIFLASH_NSS_GPIO_PORT, &GPIO_InitStructure); //初始化为推挽输出
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = SPIFLASH_SCK_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(SPIFLASH_SCK_GPIO_PORT, &GPIO_InitStructure); //初始化为复用推挽输出
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = SPIFLASH_MOSI_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(SPIFLASH_MOSI_GPIO_PORT, &GPIO_InitStructure); //初始化为复用推挽输出
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_InitStructure.GPIO_Pin = SPIFLASH_MISO_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(SPIFLASH_MISO_GPIO_PORT, &GPIO_InitStructure); //将PA6引脚初始化为上拉输入
|
||||
|
||||
/*SPI初始化*/
|
||||
|
||||
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //模式,选择为SPI主模式
|
||||
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //方向,选择2线全双工
|
||||
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //数据宽度,选择为8位
|
||||
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //先行位,选择高位先行
|
||||
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128; //波特率分频,选择128分频
|
||||
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //SPI极性,选择低极性
|
||||
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //SPI相位,选择第一个时钟边沿采样,极性和相位决定选择SPI模式0
|
||||
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //NSS,选择由软件控制
|
||||
SPI_InitStructure.SPI_CRCPolynomial = 7; //CRC多项式,暂时用不到,给默认值7
|
||||
SPI_Init(SPIFLASH_PERIPH_TYPE, &SPI_InitStructure); //将结构体变量交给SPI_Init,配置SPI1
|
||||
|
||||
/*SPI使能*/
|
||||
SPI_Cmd(SPIFLASH_PERIPH_TYPE, ENABLE); //使能SPI1,开始运行
|
||||
|
||||
/*设置默认电平*/
|
||||
MySPI_W_SS(1); //SS默认高电平
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:SPI起始
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void MySPI_Start(void)
|
||||
{
|
||||
MySPI_W_SS(0); //拉低SS,开始时序
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:SPI终止
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void MySPI_Stop(void)
|
||||
{
|
||||
MySPI_W_SS(1); //拉高SS,终止时序
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:SPI交换传输一个字节,使用SPI模式0
|
||||
* 参 数:ByteSend 要发送的一个字节
|
||||
* 返 回 值:接收的一个字节
|
||||
*/
|
||||
uint8_t MySPI_SwapByte(uint8_t ByteSend)
|
||||
{
|
||||
while (SPI_I2S_GetFlagStatus(SPIFLASH_PERIPH_TYPE, SPI_I2S_FLAG_TXE) != SET); //等待发送数据寄存器空
|
||||
|
||||
SPI_I2S_SendData(SPIFLASH_PERIPH_TYPE, ByteSend); //写入数据到发送数据寄存器,开始产生时序
|
||||
|
||||
while (SPI_I2S_GetFlagStatus(SPIFLASH_PERIPH_TYPE, SPI_I2S_FLAG_RXNE) != SET); //等待接收数据寄存器非空
|
||||
|
||||
return SPI_I2S_ReceiveData(SPIFLASH_PERIPH_TYPE); //读取接收到的数据并返回
|
||||
}
|
||||
9
Code/middleware/SPI_Flash/MySPI.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __MYSPI_H
|
||||
#define __MYSPI_H
|
||||
|
||||
void MySPI_Init(void);
|
||||
void MySPI_Start(void);
|
||||
void MySPI_Stop(void);
|
||||
uint8_t MySPI_SwapByte(uint8_t ByteSend);
|
||||
|
||||
#endif
|
||||
134
Code/middleware/SPI_Flash/W25Q64.c
Normal file
@ -0,0 +1,134 @@
|
||||
#include "stm32f10x.h" // Device header
|
||||
#include "MySPI.h"
|
||||
#include "W25Q64_Ins.h"
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64初始化
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_Init(void)
|
||||
{
|
||||
MySPI_Init(); //先初始化底层的SPI
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64读取ID号
|
||||
* 参 数:MID 工厂ID,使用输出参数的形式返回
|
||||
* 参 数:DID 设备ID,使用输出参数的形式返回
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_ReadID(uint8_t *MID, uint16_t *DID)
|
||||
{
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_JEDEC_ID); //交换发送读取ID的指令
|
||||
*MID = MySPI_SwapByte(W25Q64_DUMMY_BYTE); //交换接收MID,通过输出参数返回
|
||||
*DID = MySPI_SwapByte(W25Q64_DUMMY_BYTE); //交换接收DID高8位
|
||||
*DID <<= 8; //高8位移到高位
|
||||
*DID |= MySPI_SwapByte(W25Q64_DUMMY_BYTE); //或上交换接收DID的低8位,通过输出参数返回
|
||||
MySPI_Stop(); //SPI终止
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64写使能
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_WriteEnable(void)
|
||||
{
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_WRITE_ENABLE); //交换发送写使能的指令
|
||||
MySPI_Stop(); //SPI终止
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64等待忙
|
||||
* 参 数:无
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_WaitBusy(void)
|
||||
{
|
||||
uint32_t Timeout;
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_READ_STATUS_REGISTER_1); //交换发送读状态寄存器1的指令
|
||||
Timeout = 100000; //给定超时计数时间
|
||||
while ((MySPI_SwapByte(W25Q64_DUMMY_BYTE) & 0x01) == 0x01) //循环等待忙标志位
|
||||
{
|
||||
Timeout --; //等待时,计数值自减
|
||||
if (Timeout == 0) //自减到0后,等待超时
|
||||
{
|
||||
/*超时的错误处理代码,可以添加到此处*/
|
||||
break; //跳出等待,不等了
|
||||
}
|
||||
}
|
||||
MySPI_Stop(); //SPI终止
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64页编程
|
||||
* 参 数:Address 页编程的起始地址,范围:0x000000~0x7FFFFF
|
||||
* 参 数:DataArray 用于写入数据的数组
|
||||
* 参 数:Count 要写入数据的数量,范围:0~256
|
||||
* 返 回 值:无
|
||||
* 注意事项:写入的地址范围不能跨页
|
||||
*/
|
||||
void W25Q64_PageProgram(uint32_t Address, uint8_t *DataArray, uint16_t Count)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
W25Q64_WriteEnable(); //写使能
|
||||
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_PAGE_PROGRAM); //交换发送页编程的指令
|
||||
MySPI_SwapByte(Address >> 16); //交换发送地址23~16位
|
||||
MySPI_SwapByte(Address >> 8); //交换发送地址15~8位
|
||||
MySPI_SwapByte(Address); //交换发送地址7~0位
|
||||
for (i = 0; i < Count; i ++) //循环Count次
|
||||
{
|
||||
MySPI_SwapByte(DataArray[i]); //依次在起始地址后写入数据
|
||||
}
|
||||
MySPI_Stop(); //SPI终止
|
||||
|
||||
W25Q64_WaitBusy(); //等待忙
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64扇区擦除(4KB)
|
||||
* 参 数:Address 指定扇区的地址,范围:0x000000~0x7FFFFF
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_SectorErase(uint32_t Address)
|
||||
{
|
||||
W25Q64_WriteEnable(); //写使能
|
||||
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_SECTOR_ERASE_4KB); //交换发送扇区擦除的指令
|
||||
MySPI_SwapByte(Address >> 16); //交换发送地址23~16位
|
||||
MySPI_SwapByte(Address >> 8); //交换发送地址15~8位
|
||||
MySPI_SwapByte(Address); //交换发送地址7~0位
|
||||
MySPI_Stop(); //SPI终止
|
||||
|
||||
W25Q64_WaitBusy(); //等待忙
|
||||
}
|
||||
|
||||
/**
|
||||
* 函 数:W25Q64读取数据
|
||||
* 参 数:Address 读取数据的起始地址,范围:0x000000~0x7FFFFF
|
||||
* 参 数:DataArray 用于接收读取数据的数组,通过输出参数返回
|
||||
* 参 数:Count 要读取数据的数量,范围:0~0x800000
|
||||
* 返 回 值:无
|
||||
*/
|
||||
void W25Q64_ReadData(uint32_t Address, uint8_t *DataArray, uint32_t Count)
|
||||
{
|
||||
uint32_t i;
|
||||
MySPI_Start(); //SPI起始
|
||||
MySPI_SwapByte(W25Q64_READ_DATA); //交换发送读取数据的指令
|
||||
MySPI_SwapByte(Address >> 16); //交换发送地址23~16位
|
||||
MySPI_SwapByte(Address >> 8); //交换发送地址15~8位
|
||||
MySPI_SwapByte(Address); //交换发送地址7~0位
|
||||
for (i = 0; i < Count; i ++) //循环Count次
|
||||
{
|
||||
DataArray[i] = MySPI_SwapByte(W25Q64_DUMMY_BYTE); //依次在起始地址后读取数据
|
||||
}
|
||||
MySPI_Stop(); //SPI终止
|
||||
}
|
||||
11
Code/middleware/SPI_Flash/W25Q64.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __W25Q64_H
|
||||
#define __W25Q64_H
|
||||
|
||||
#include <stdint.h>
|
||||
void W25Q64_Init(void);
|
||||
void W25Q64_ReadID(uint8_t *MID, uint16_t *DID);
|
||||
void W25Q64_PageProgram(uint32_t Address, uint8_t *DataArray, uint16_t Count);
|
||||
void W25Q64_SectorErase(uint32_t Address);
|
||||
void W25Q64_ReadData(uint32_t Address, uint8_t *DataArray, uint32_t Count);
|
||||
|
||||
#endif
|
||||
34
Code/middleware/SPI_Flash/W25Q64_Ins.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef __W25Q64_INS_H
|
||||
#define __W25Q64_INS_H
|
||||
|
||||
#define W25Q64_WRITE_ENABLE 0x06
|
||||
#define W25Q64_WRITE_DISABLE 0x04
|
||||
#define W25Q64_READ_STATUS_REGISTER_1 0x05
|
||||
#define W25Q64_READ_STATUS_REGISTER_2 0x35
|
||||
#define W25Q64_WRITE_STATUS_REGISTER 0x01
|
||||
#define W25Q64_PAGE_PROGRAM 0x02
|
||||
#define W25Q64_QUAD_PAGE_PROGRAM 0x32
|
||||
#define W25Q64_BLOCK_ERASE_64KB 0xD8
|
||||
#define W25Q64_BLOCK_ERASE_32KB 0x52
|
||||
#define W25Q64_SECTOR_ERASE_4KB 0x20
|
||||
#define W25Q64_CHIP_ERASE 0xC7
|
||||
#define W25Q64_ERASE_SUSPEND 0x75
|
||||
#define W25Q64_ERASE_RESUME 0x7A
|
||||
#define W25Q64_POWER_DOWN 0xB9
|
||||
#define W25Q64_HIGH_PERFORMANCE_MODE 0xA3
|
||||
#define W25Q64_CONTINUOUS_READ_MODE_RESET 0xFF
|
||||
#define W25Q64_RELEASE_POWER_DOWN_HPM_DEVICE_ID 0xAB
|
||||
#define W25Q64_MANUFACTURER_DEVICE_ID 0x90
|
||||
#define W25Q64_READ_UNIQUE_ID 0x4B
|
||||
#define W25Q64_JEDEC_ID 0x9F
|
||||
#define W25Q64_READ_DATA 0x03
|
||||
#define W25Q64_FAST_READ 0x0B
|
||||
#define W25Q64_FAST_READ_DUAL_OUTPUT 0x3B
|
||||
#define W25Q64_FAST_READ_DUAL_IO 0xBB
|
||||
#define W25Q64_FAST_READ_QUAD_OUTPUT 0x6B
|
||||
#define W25Q64_FAST_READ_QUAD_IO 0xEB
|
||||
#define W25Q64_OCTAL_WORD_READ_QUAD_IO 0xE3
|
||||
|
||||
#define W25Q64_DUMMY_BYTE 0xFF
|
||||
|
||||
#endif
|
||||
@ -340,7 +340,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_STDPERIPH_DRIVER</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\CoreSupport;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm;..\Code\app\inc;..\Code\bsp\inc;..\Code\isr;..\Code\middleware\internal\inc;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\STM32F10x_StdPeriph_Driver\inc;..\Code\library;..\Code\middleware\BlueTooth;..\Code\middleware\BlueTooth\HC-06;..\Code\bsp;..\Code\middleware\Led;..\Code\middleware\DebugLog;..\Code\middleware\Motor;..\Code\middleware\IrController</IncludePath>
|
||||
<IncludePath>..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\CoreSupport;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm;..\Code\app\inc;..\Code\bsp\inc;..\Code\isr;..\Code\middleware\internal\inc;..\Code\library\STM32F10x_StdPeriph_Lib_V3.6.0\Libraries\STM32F10x_StdPeriph_Driver\inc;..\Code\library;..\Code\middleware\BlueTooth;..\Code\middleware\BlueTooth\HC-06;..\Code\bsp;..\Code\middleware\Led;..\Code\middleware\DebugLog;..\Code\middleware\Motor;..\Code\middleware\IrController;..\Code\middleware\Oled_096;..\Code\middleware\SPI_Flash</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@ -432,6 +432,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\bsp\src\bsp_motor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_oled.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\bsp\src\bsp_oled.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\bsp\src\bsp_flash.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@ -657,6 +667,31 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>MW/OLED096</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>OLED.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\middleware\Oled_096\OLED.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>MW/SPI_FLASH</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>W25Q64.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\middleware\SPI_Flash\W25Q64.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MySPI.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Code\middleware\SPI_Flash\MySPI.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||