[X9D] RTC. Tx Setup cosmetics
This commit is contained in:
+24
-13
@@ -70,7 +70,15 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = {
|
||||
menuGeneralCalib
|
||||
};
|
||||
|
||||
#if LCD >= 212
|
||||
#define RADIO_SETUP_2ND_COLUMN (DISPLAY_W-10*FW-MENUS_SCROLLBAR_WIDTH)
|
||||
#define RADIO_SETUP_DATE_COLUMN RADIO_SETUP_2ND_COLUMN + 4*FWNUM
|
||||
#define RADIO_SETUP_TIME_COLUMN RADIO_SETUP_2ND_COLUMN + 2*FWNUM
|
||||
#else
|
||||
#define RADIO_SETUP_2ND_COLUMN (DISPLAY_W-5*FW-MENUS_SCROLLBAR_WIDTH)
|
||||
#define RADIO_SETUP_TIME_COLUMN (FW*15+5)
|
||||
#define RADIO_SETUP_DATE_COLUMN (FW*15+5)
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS)
|
||||
void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr)
|
||||
@@ -102,7 +110,7 @@ enum menuGeneralSetupItems {
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_LENGTH)
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_STRENGTH)
|
||||
IF_PCBSKY9X(ITEM_SETUP_BRIGHTNESS)
|
||||
ITEM_SETUP_CONTRAST,
|
||||
IF_9X(ITEM_SETUP_CONTRAST)
|
||||
ITEM_SETUP_ALARMS_LABEL,
|
||||
ITEM_SETUP_BATTERY_WARNING,
|
||||
IF_PCBSKY9X(ITEM_SETUP_CAPACITY_WARNING)
|
||||
@@ -130,6 +138,7 @@ enum menuGeneralSetupItems {
|
||||
ITEM_SETUP_MAX
|
||||
};
|
||||
|
||||
|
||||
void menuGeneralSetup(uint8_t event)
|
||||
{
|
||||
#if defined(RTCLOCK)
|
||||
@@ -139,7 +148,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_CPUARM(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/});
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) LABEL(SOUND), 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) IF_9X(0) LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_CPUARM(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, LABEL(TIMER_EVENTS), 0, 0, LABEL(BACKLIGHT), 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, LABEL(TX_MODE), IF_PCBX9D(0) 1/*to force edit mode*/});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -153,16 +162,16 @@ void menuGeneralSetup(uint8_t event)
|
||||
#if defined(RTCLOCK)
|
||||
case ITEM_SETUP_DATE:
|
||||
lcd_putsLeft(y, STR_DATE);
|
||||
lcd_putc(FW*15+5, y, '-'); lcd_putc(FW*18+3, y, '-');
|
||||
lcd_putc(RADIO_SETUP_DATE_COLUMN, y, '-'); lcd_putc(RADIO_SETUP_DATE_COLUMN+3*FW-1, y, '-');
|
||||
for (uint8_t j=0; j<3; j++) {
|
||||
uint8_t rowattr = (m_posHorz==j) ? attr : 0;
|
||||
switch (j) {
|
||||
case 0:
|
||||
lcd_outdezAtt(FW*15+5, y, t.tm_year+1900, rowattr);
|
||||
lcd_outdezAtt(RADIO_SETUP_DATE_COLUMN, y, t.tm_year+1900, rowattr);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0);
|
||||
break;
|
||||
case 1:
|
||||
lcd_outdezNAtt(FW*18+3, y, t.tm_mon+1, rowattr|LEADING0, 2);
|
||||
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+3*FW-1, y, t.tm_mon+1, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_mon = checkIncDec(event, t.tm_mon, 0, 11, 0);
|
||||
break;
|
||||
case 2:
|
||||
@@ -171,7 +180,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
int8_t dlim = (((((year%4==0) && (year %100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0);
|
||||
int8_t dmon[] = {31,28,31,30,31,30,31,31,30,31,30,31}; // TODO in flash
|
||||
dlim += dmon[t.tm_mon];
|
||||
lcd_outdezNAtt(FW*21+2, y, t.tm_mday, rowattr|LEADING0, 2);
|
||||
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-2, y, t.tm_mday, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0);
|
||||
break;
|
||||
}
|
||||
@@ -186,21 +195,21 @@ void menuGeneralSetup(uint8_t event)
|
||||
|
||||
case ITEM_SETUP_TIME:
|
||||
lcd_putsLeft(y, STR_TIME);
|
||||
lcd_putc(FW*15+5, y, ':'); lcd_putc(FW*18+3, y, ':');
|
||||
lcd_putc(RADIO_SETUP_TIME_COLUMN-1, y, ':'); lcd_putc(RADIO_SETUP_TIME_COLUMN+3*FW-4, y, ':');
|
||||
for (uint8_t j=0; j<3; j++) {
|
||||
uint8_t rowattr = (m_posHorz==j) ? attr : 0;
|
||||
switch (j) {
|
||||
case 0:
|
||||
lcd_outdezNAtt(FW*15+5, y, t.tm_hour, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_hour = checkIncDec( event, t.tm_hour, 0, 23, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN, y, t.tm_hour, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_hour = checkIncDec(event, t.tm_hour, 0, 23, 0);
|
||||
break;
|
||||
case 1:
|
||||
lcd_outdezNAtt(FW*18+3, y, t.tm_min, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_min = checkIncDec( event, t.tm_min, 0, 59, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN+3*FWNUM, y, t.tm_min, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_min = checkIncDec(event, t.tm_min, 0, 59, 0);
|
||||
break;
|
||||
case 2:
|
||||
lcd_outdezNAtt(FW*21+2, y, t.tm_sec, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_sec = checkIncDec( event, t.tm_sec, 0, 59, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_TIME_COLUMN+6*FWNUM, y, t.tm_sec, rowattr|LEADING0, 2);
|
||||
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_sec = checkIncDec(event, t.tm_sec, 0, 59, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -297,6 +306,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(PCBX9D) && !defined(PCBACT)
|
||||
case ITEM_SETUP_CONTRAST:
|
||||
lcd_putsLeft( y, STR_CONTRAST);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN,y,g_eeGeneral.contrast, attr|LEFT);
|
||||
@@ -305,6 +315,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
lcdSetContrast();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_SETUP_ALARMS_LABEL:
|
||||
lcd_putsLeft(y, STR_ALARMS_LABEL);
|
||||
|
||||
+36
-42
@@ -228,46 +228,40 @@ int iic_write (
|
||||
return cnt ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------*/
|
||||
/* RTC functions */
|
||||
|
||||
|
||||
int g9x_rtc_gettime (RTC *rtc)
|
||||
{
|
||||
BYTE buf[8];
|
||||
BYTE buf[8];
|
||||
|
||||
if (!iic_read(0xD0, 0, 7, buf)) return 0;
|
||||
if (!iic_read(0xD0, 0, 7, buf)) return 0;
|
||||
|
||||
rtc->sec = (buf[0] & 0x0F) + ((buf[0] >> 4) & 7) * 10;
|
||||
rtc->min = (buf[1] & 0x0F) + (buf[1] >> 4) * 10;
|
||||
rtc->hour = (buf[2] & 0x0F) + ((buf[2] >> 4) & 3) * 10;
|
||||
rtc->wday = (buf[2] & 0x07);
|
||||
rtc->mday = (buf[4] & 0x0F) + ((buf[4] >> 4) & 3) * 10;
|
||||
rtc->month = (buf[5] & 0x0F) + ((buf[5] >> 4) & 1) * 10;
|
||||
rtc->year = 2000 + (buf[6] & 0x0F) + (buf[6] >> 4) * 10;
|
||||
rtc->sec = (buf[0] & 0x0F) + ((buf[0] >> 4) & 7) * 10;
|
||||
rtc->min = (buf[1] & 0x0F) + (buf[1] >> 4) * 10;
|
||||
rtc->hour = (buf[2] & 0x0F) + ((buf[2] >> 4) & 3) * 10;
|
||||
rtc->wday = (buf[2] & 0x07);
|
||||
rtc->mday = (buf[4] & 0x0F) + ((buf[4] >> 4) & 3) * 10;
|
||||
rtc->month = (buf[5] & 0x0F) + ((buf[5] >> 4) & 1) * 10;
|
||||
rtc->year = 2000 + (buf[6] & 0x0F) + (buf[6] >> 4) * 10;
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int g9x_rtc_settime (const RTC *rtc)
|
||||
{
|
||||
BYTE buf[8];
|
||||
BYTE buf[8];
|
||||
|
||||
buf[0] = rtc->sec / 10 * 16 + rtc->sec % 10;
|
||||
buf[1] = rtc->min / 10 * 16 + rtc->min % 10;
|
||||
buf[2] = rtc->hour / 10 * 16 + rtc->hour % 10;
|
||||
buf[3] = rtc->wday & 7;
|
||||
buf[4] = rtc->mday / 10 * 16 + rtc->mday % 10;
|
||||
buf[5] = rtc->month / 10 * 16 + rtc->month % 10;
|
||||
buf[6] = (rtc->year - 2000) / 10 * 16 + (rtc->year - 2000) % 10;
|
||||
return iic_write(0xD0, 0, 7, buf);
|
||||
buf[0] = rtc->sec / 10 * 16 + rtc->sec % 10;
|
||||
buf[1] = rtc->min / 10 * 16 + rtc->min % 10;
|
||||
buf[2] = rtc->hour / 10 * 16 + rtc->hour % 10;
|
||||
buf[3] = rtc->wday & 7;
|
||||
buf[4] = rtc->mday / 10 * 16 + rtc->mday % 10;
|
||||
buf[5] = rtc->month / 10 * 16 + rtc->month % 10;
|
||||
buf[6] = (rtc->year - 2000) / 10 * 16 + (rtc->year - 2000) % 10;
|
||||
return iic_write(0xD0, 0, 7, buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void rtc_gettime(struct gtm * utm)
|
||||
{
|
||||
RTC rtc = {0,0,0,0,0,0,0};
|
||||
@@ -299,27 +293,27 @@ void rtc_settime(struct gtm * t)
|
||||
g9x_rtc_settime(&rtc);
|
||||
}
|
||||
|
||||
void rtc_init (void)
|
||||
void rtcInit (void)
|
||||
{
|
||||
BYTE buf[8]; /* RTC R/W buffer */
|
||||
UINT adr;
|
||||
BYTE buf[8]; /* RTC R/W buffer */
|
||||
UINT adr;
|
||||
|
||||
|
||||
/* Read RTC registers */
|
||||
if (!iic_read(0xD0, 0, 8, buf)) return; /* IIC error */
|
||||
/* Read RTC registers */
|
||||
if (!iic_read(0xD0, 0, 8, buf)) return; /* IIC error */
|
||||
|
||||
if (buf[7] & 0x20) { /* When data has been volatiled, set default time */
|
||||
/* Clear nv-ram. Reg[8..63] */
|
||||
memset(buf, 0, 8);
|
||||
for (adr = 8; adr < 64; adr += 8)
|
||||
iic_write(0x0D, adr, 8, buf);
|
||||
/* Reset time to Jan 1, '08. Reg[0..7] */
|
||||
buf[4] = 1; buf[5] = 1; buf[6] = 8;
|
||||
iic_write(0x0D, 0, 8, buf);
|
||||
}
|
||||
if (buf[7] & 0x20) { /* When data has been volatiled, set default time */
|
||||
/* Clear nv-ram. Reg[8..63] */
|
||||
memset(buf, 0, 8);
|
||||
for (adr = 8; adr < 64; adr += 8)
|
||||
iic_write(0x0D, adr, 8, buf);
|
||||
/* Reset time to Jan 1, '08. Reg[0..7] */
|
||||
buf[4] = 1; buf[5] = 1; buf[6] = 8;
|
||||
iic_write(0x0D, 0, 8, buf);
|
||||
}
|
||||
|
||||
struct gtm utm;
|
||||
rtc_gettime(&utm);
|
||||
g_rtcTime = gmktime(&utm);
|
||||
struct gtm utm;
|
||||
rtc_gettime(&utm);
|
||||
g_rtcTime = gmktime(&utm);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,4 +252,6 @@ void drawStatusLine();
|
||||
|
||||
void menuChannelsMonitor(uint8_t event);
|
||||
|
||||
#define LABEL(...) (uint8_t)-1
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -250,7 +250,7 @@ void per10ms()
|
||||
g_rtcTime++; // inc global unix timestamp one second
|
||||
#if defined(PCBSKY9X)
|
||||
if (g_rtcTime < 60 || rtc_count<5) {
|
||||
rtc_init();
|
||||
rtcInit();
|
||||
rtc_count++;
|
||||
}
|
||||
else {
|
||||
@@ -3420,7 +3420,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
#endif
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
rtc_init();
|
||||
rtcInit();
|
||||
#endif
|
||||
|
||||
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBACT)
|
||||
#define IF_9X(x)
|
||||
#else
|
||||
#define IF_9X(x) x,
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#define IF_PCBSKY9X(x) x,
|
||||
#else
|
||||
|
||||
@@ -53,13 +53,14 @@ struct gtm
|
||||
extern gtime_t g_rtcTime;
|
||||
extern uint8_t g_ms100; // global to allow time set function to reset to zero
|
||||
|
||||
void rtcInit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void rtc_init();
|
||||
extern void rtc_settime(struct gtm * tm);
|
||||
extern void gettime(struct gtm * tm);
|
||||
extern gtime_t gmktime (struct gtm *tm);
|
||||
void rtc_settime(struct gtm * tm);
|
||||
void gettime(struct gtm * tm);
|
||||
gtime_t gmktime (struct gtm *tm);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -630,3 +630,19 @@ void lcdRefresh()
|
||||
lcd_refresh = true;
|
||||
}
|
||||
|
||||
#if defined(PCBX9D)
|
||||
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct) { return SUCCESS; }
|
||||
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct) { return SUCCESS; }
|
||||
void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct) { }
|
||||
void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct) { }
|
||||
void PWR_BackupAccessCmd(FunctionalState NewState) { }
|
||||
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource) { }
|
||||
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState) { }
|
||||
void RCC_RTCCLKCmd(FunctionalState NewState) { }
|
||||
ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct) { return SUCCESS; }
|
||||
void USART_SendData(USART_TypeDef* USARTx, uint16_t Data) { }
|
||||
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG) { return SET; }
|
||||
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF) { }
|
||||
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) { }
|
||||
void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState) { }
|
||||
#endif
|
||||
|
||||
@@ -372,11 +372,7 @@ void read_volume()
|
||||
|
||||
void read_coprocessor(bool onlytemp)
|
||||
{
|
||||
if (onlytemp) {
|
||||
get_onlytemp=true;
|
||||
} else {
|
||||
get_onlytemp=false;
|
||||
}
|
||||
get_onlytemp = onlytemp;
|
||||
CoProc_read_pending = 1 ;
|
||||
__disable_irq() ;
|
||||
i2c_check_for_request() ;
|
||||
|
||||
@@ -55,7 +55,7 @@ void rtc_settime(struct gtm * t)
|
||||
write_coprocessor( (uint8_t *) &I2CTime, 8 ) ;
|
||||
}
|
||||
|
||||
void rtc_init()
|
||||
void rtcInit()
|
||||
{
|
||||
read_coprocessor();
|
||||
}
|
||||
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/adc/adc.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides adc Init and drivers.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "adc.h"
|
||||
#include "hal.h"
|
||||
#include "msg_que.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "item.h"
|
||||
|
||||
|
||||
|
||||
#define ADC1_DR_ADDRESS ((uint32_t)0x4001204C)
|
||||
//#define ADC2_DR_ADDRESS ((uint32_t)0x4001214C)
|
||||
//#define ADC3_DR_ADDRESS ((uint32_t)0x4001224C)
|
||||
|
||||
__IO uint16_t ADC1ConvertedValue[10] = {0};
|
||||
|
||||
|
||||
void adc_clk_init()
|
||||
{
|
||||
/* Enable peripheral clocks *************************************************/
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOADC, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void adc_gpio_init()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
//AIN state
|
||||
/* Configure ADC1 Channel5 pin as analog input ******************************/
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
}
|
||||
void adc_init() //one adc
|
||||
{
|
||||
ADC_InitTypeDef ADC_InitStructure;
|
||||
ADC_CommonInitTypeDef ADC_CommonInitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
|
||||
adc_clk_init();//enable
|
||||
adc_gpio_init();//AIN
|
||||
|
||||
/* ADC1 regular channel configuration ************************************/
|
||||
ADC_InitStructure.ADC_Resolution = ADC_Resolution_10b;
|
||||
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //
|
||||
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; //
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; //
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfConversion = 1;//
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
|
||||
/* ADC Common configuration ********************** ***************************/
|
||||
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;//one ADC
|
||||
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_6Cycles;//6* 1/30M
|
||||
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;//
|
||||
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; //60M/2
|
||||
ADC_CommonInit(&ADC_CommonInitStructure);
|
||||
|
||||
/* ADC1 regular channel configuration */
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 1, ADC_SampleTime_3Cycles);//
|
||||
|
||||
|
||||
/* DMA2 Stream0 channel0 configuration **************************************/
|
||||
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_ADDRESS;
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)ADC1ConvertedValue;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
|
||||
DMA_InitStructure.DMA_BufferSize = 1;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
|
||||
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
|
||||
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
|
||||
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
|
||||
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
|
||||
DMA_Cmd(DMA2_Stream0, ENABLE);
|
||||
|
||||
/* Enable DMA request after last transfer (Single-ADC mode) */
|
||||
ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 DMA */
|
||||
ADC_DMACmd(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 */
|
||||
ADC_Cmd(ADC1, ENABLE);
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/adc/adc.h
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides adc Init and drivers.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef _ADC_INIT_H_
|
||||
#define _ADC_INIT_H_
|
||||
|
||||
|
||||
void adc_init();
|
||||
#endif
|
||||
+8
-2
@@ -48,8 +48,6 @@
|
||||
#include "aspi.h"
|
||||
#include "i2c_ee.h"
|
||||
#include "audio_driver.h"
|
||||
#include "delays.h"
|
||||
#include "uart.h"
|
||||
|
||||
#define PERI1_FREQUENCY 30000000
|
||||
#define PERI2_FREQUENCY 60000000
|
||||
@@ -130,4 +128,12 @@ extern volatile uint16_t Analog_values[];
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config );
|
||||
|
||||
#define DEBUG_UART_BAUDRATE 115200
|
||||
|
||||
void uartInit(void);
|
||||
void uartSendChar(uint8_t c);
|
||||
|
||||
void delaysInit(void);
|
||||
void delay_01us(uint16_t nb);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DELAYS_H
|
||||
#define __DELAYS_H
|
||||
|
||||
void delaysInit(void);
|
||||
void delay_01us(uint16_t nb);
|
||||
|
||||
|
||||
#endif //__DELAYS_H
|
||||
-282
@@ -1,282 +0,0 @@
|
||||
/*-------------------------------------------------------------------------- */
|
||||
/* RTC controls for STM32 */
|
||||
/* Copyright (c) 2009, Martin Thomas 4/2009, 3BSD-license */
|
||||
/* partly based on code from STMircoelectronics, Peter Dannegger, "LaLaDumm" */
|
||||
/*-------------------------------------------------------------------------- */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stm32f10x.h"
|
||||
#include "rtc.h"
|
||||
|
||||
#define FIRSTYEAR 2000 // start year
|
||||
#define FIRSTDAY 6 // 0 = Sunday
|
||||
|
||||
static const uint8_t DaysInMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : isDST
|
||||
* Description : checks if given time is in Daylight Saving time-span.
|
||||
* Input : time-struct, must be fully populated including weekday
|
||||
* Output : none
|
||||
* Return : false: no DST ("winter"), true: in DST ("summer")
|
||||
* DST according to German standard
|
||||
* Based on code from Peter Dannegger found in the microcontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static bool isDST( const RTC_t *t )
|
||||
{
|
||||
uint8_t wday, month; // locals for faster access
|
||||
|
||||
month = t->month;
|
||||
|
||||
if( month < 3 || month > 10 ) { // month 1, 2, 11, 12
|
||||
return false; // -> Winter
|
||||
}
|
||||
|
||||
wday = t->wday;
|
||||
|
||||
if( t->mday - wday >= 25 && (wday || t->hour >= 2) ) { // after last Sunday 2:00
|
||||
if( month == 10 ) { // October -> Winter
|
||||
return false;
|
||||
}
|
||||
} else { // before last Sunday 2:00
|
||||
if( month == 3 ) { // March -> Winter
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : adjustDST
|
||||
* Description : adjusts time to DST if needed
|
||||
* Input : non DST time-struct, must be fully populated including weekday
|
||||
* Output : time-stuct gets modified
|
||||
* Return : false: no DST ("winter"), true: in DST ("summer")
|
||||
* DST according to German standard
|
||||
* Based on code from Peter Dannegger found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static bool adjustDST( RTC_t *t )
|
||||
{
|
||||
uint8_t hour, day, wday, month; // locals for faster access
|
||||
|
||||
hour = t->hour;
|
||||
day = t->mday;
|
||||
wday = t->wday;
|
||||
month = t->month;
|
||||
|
||||
if ( isDST(t) ) {
|
||||
t->dst = 1;
|
||||
hour++; // add one hour
|
||||
if( hour == 24 ){ // next day
|
||||
hour = 0;
|
||||
wday++; // next weekday
|
||||
if( wday == 7 ) {
|
||||
wday = 0;
|
||||
}
|
||||
if( day == DaysInMonth[month-1] ) { // next month
|
||||
day = 0;
|
||||
month++;
|
||||
}
|
||||
day++;
|
||||
}
|
||||
t->month = month;
|
||||
t->hour = hour;
|
||||
t->mday = day;
|
||||
t->wday = wday;
|
||||
return true;
|
||||
} else {
|
||||
t->dst = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : counter_to_struct
|
||||
* Description : populates time-struct based on counter-value
|
||||
* Input : - counter-value (unit seconds, 0 -> 1.1.2000 00:00:00),
|
||||
* - Pointer to time-struct
|
||||
* Output : time-struct gets populated, DST not taken into account here
|
||||
* Return : none
|
||||
* Based on code from Peter Dannegger found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static void counter_to_struct( uint32_t sec, RTC_t *t )
|
||||
{
|
||||
uint16_t day;
|
||||
uint8_t year;
|
||||
uint16_t dayofyear;
|
||||
uint8_t leap400;
|
||||
uint8_t month;
|
||||
|
||||
t->sec = sec % 60;
|
||||
sec /= 60;
|
||||
t->min = sec % 60;
|
||||
sec /= 60;
|
||||
t->hour = sec % 24;
|
||||
day = (uint16_t)(sec / 24);
|
||||
|
||||
t->wday = (day + FIRSTDAY) % 7; // weekday
|
||||
|
||||
year = FIRSTYEAR % 100; // 0..99
|
||||
leap400 = 4 - ((FIRSTYEAR - 1) / 100 & 3); // 4, 3, 2, 1
|
||||
|
||||
for(;;) {
|
||||
dayofyear = 365;
|
||||
if( (year & 3) == 0 ) {
|
||||
dayofyear = 366; // leap year
|
||||
if( year == 0 || year == 100 || year == 200 ) { // 100 year exception
|
||||
if( --leap400 ) { // 400 year exception
|
||||
dayofyear = 365;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( day < dayofyear ) {
|
||||
break;
|
||||
}
|
||||
day -= dayofyear;
|
||||
year++; // 00..136 / 99..235
|
||||
}
|
||||
t->year = year + FIRSTYEAR / 100 * 100; // + century
|
||||
|
||||
if( dayofyear & 1 && day > 58 ) { // no leap year and after 28.2.
|
||||
day++; // skip 29.2.
|
||||
}
|
||||
|
||||
for( month = 1; day >= DaysInMonth[month-1]; month++ ) {
|
||||
day -= DaysInMonth[month-1];
|
||||
}
|
||||
|
||||
t->month = month; // 1..12
|
||||
t->mday = day + 1; // 1..31
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : struct_to_counter
|
||||
* Description : calculates second-counter from populated time-struct
|
||||
* Input : Pointer to time-struct
|
||||
* Output : none
|
||||
* Return : counter-value (unit seconds, 0 -> 1.1.2000 00:00:00),
|
||||
* Based on code from "LalaDumm" found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static uint32_t struct_to_counter( const RTC_t *t )
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t result = 0;
|
||||
uint16_t idx, year;
|
||||
|
||||
year = t->year;
|
||||
|
||||
/* Calculate days of years before */
|
||||
result = (uint32_t)year * 365;
|
||||
if (t->year >= 1) {
|
||||
result += (year + 3) / 4;
|
||||
result -= (year - 1) / 100;
|
||||
result += (year - 1) / 400;
|
||||
}
|
||||
|
||||
/* Start with 2000 a.d. */
|
||||
result -= 730485UL;
|
||||
|
||||
/* Make month an array index */
|
||||
idx = t->month - 1;
|
||||
|
||||
/* Loop thru each month, adding the days */
|
||||
for (i = 0; i < idx; i++) {
|
||||
result += DaysInMonth[i];
|
||||
}
|
||||
|
||||
/* Leap year? adjust February */
|
||||
if (year%400 == 0 || (year%4 == 0 && year%100 !=0)) {
|
||||
;
|
||||
} else {
|
||||
if (t->month > 1) {
|
||||
result--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add remaining days */
|
||||
result += t->mday;
|
||||
|
||||
/* Convert to seconds, add all the other stuff */
|
||||
result = (result-1) * 86400L + (uint32_t)t->hour * 3600 +
|
||||
(uint32_t)t->min * 60 + t->sec;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_gettime
|
||||
* Description : populates structure from HW-RTC, takes DST into account
|
||||
* Input : None
|
||||
* Output : time-struct gets modified
|
||||
* Return : always true/not used
|
||||
*******************************************************************************/
|
||||
bool rtc_gettime (RTC_t *rtc)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
while ( ( t = RTC_GetCounter() ) != RTC_GetCounter() ) { ; }
|
||||
counter_to_struct( t, rtc ); // get non DST time
|
||||
adjustDST( rtc );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : my_RTC_SetCounter
|
||||
* Description : sets the hardware-counter
|
||||
* Input : new counter-value
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
static void my_RTC_SetCounter(uint32_t cnt)
|
||||
{
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
RTC_WaitForLastTask();
|
||||
/* Change the current time */
|
||||
RTC_SetCounter(cnt);
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
RTC_WaitForLastTask();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_settime
|
||||
* Description : sets HW-RTC with values from time-struct, takes DST into
|
||||
* account, HW-RTC always running in non-DST time
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : not used
|
||||
*******************************************************************************/
|
||||
bool rtc_settime (const RTC_t *rtc)
|
||||
{
|
||||
uint32_t cnt;
|
||||
RTC_t ts;
|
||||
|
||||
cnt = struct_to_counter( rtc ); // non-DST counter-value
|
||||
counter_to_struct( cnt, &ts ); // normalize struct (for weekday)
|
||||
if ( isDST( &ts ) ) {
|
||||
cnt -= 60*60; // Subtract one hour
|
||||
}
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
my_RTC_SetCounter( cnt );
|
||||
PWR_BackupAccessCmd(DISABLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_init
|
||||
* Description : initializes HW RTC,
|
||||
* sets default time-stamp if RTC has not been initialized before
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : not used
|
||||
* see STM RTC example in the StdPeriph-Library package
|
||||
*******************************************************************************/
|
||||
int rtc_init(void) //not use back_vcc
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef RTC_H_
|
||||
#define RTC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
//#include "interger.h"
|
||||
//#include <stdbool.h>
|
||||
#include "stm32f2xx.h"
|
||||
#ifndef false
|
||||
#define false FALSE
|
||||
#endif
|
||||
#ifndef true
|
||||
#define true TRUE
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint16_t year; /* 1..4095 */
|
||||
uint8_t month; /* 1..12 */
|
||||
uint8_t mday; /* 1..31 */
|
||||
uint8_t wday; /* 0..6, Sunday = 0*/
|
||||
uint8_t hour; /* 0..23 */
|
||||
uint8_t min; /* 0..59 */
|
||||
uint8_t sec; /* 0..59 */
|
||||
uint8_t dst; /* 0 Winter, !=0 Summer */
|
||||
} RTC_t;
|
||||
|
||||
int rtc_init(void);
|
||||
bool rtc_gettime (RTC_t*); /* Get time */
|
||||
bool rtc_settime (const RTC_t*); /* Set time */
|
||||
|
||||
#endif
|
||||
+42
-38
@@ -35,49 +35,53 @@
|
||||
|
||||
void rtc_settime(struct gtm * t)
|
||||
{
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_TimeStruct.RTC_Hours = t->tm_hour;
|
||||
RTC_TimeStruct.RTC_Minutes = t->tm_min;
|
||||
RTC_TimeStruct.RTC_Seconds = t->tm_sec;
|
||||
RTC_DateStruct.RTC_Year = t->tm_year - 100;
|
||||
RTC_DateStruct.RTC_Month = t->tm_mon;
|
||||
RTC_DateStruct.RTC_Date = t->tm_mday;
|
||||
|
||||
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_TimeStruct.RTC_Hours = t->tm_hour;
|
||||
RTC_TimeStruct.RTC_Minutes = t->tm_min;
|
||||
RTC_TimeStruct.RTC_Seconds = t->tm_sec;
|
||||
RTC_DateStruct.RTC_Year = t->tm_year - 100;
|
||||
RTC_DateStruct.RTC_Month = t->tm_mon;
|
||||
RTC_DateStruct.RTC_Date = t->tm_mday;
|
||||
|
||||
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
}
|
||||
|
||||
void rtc_gettime(struct gtm * t)
|
||||
{
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
|
||||
t->tm_hour = RTC_TimeStruct.RTC_Hours;
|
||||
t->tm_min = RTC_TimeStruct.RTC_Minutes;
|
||||
t->tm_sec = RTC_TimeStruct.RTC_Seconds;
|
||||
t->tm_year = RTC_DateStruct.RTC_Year + 100;
|
||||
t->tm_mon = RTC_DateStruct.RTC_Month;
|
||||
t->tm_mday = RTC_DateStruct.RTC_Date;
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
|
||||
t->tm_hour = RTC_TimeStruct.RTC_Hours;
|
||||
t->tm_min = RTC_TimeStruct.RTC_Minutes;
|
||||
t->tm_sec = RTC_TimeStruct.RTC_Seconds;
|
||||
t->tm_year = RTC_DateStruct.RTC_Year + 100;
|
||||
t->tm_mon = RTC_DateStruct.RTC_Month;
|
||||
t->tm_mday = RTC_DateStruct.RTC_Date;
|
||||
}
|
||||
|
||||
void rtc_init()
|
||||
void rtcInit()
|
||||
{
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
|
||||
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
||||
RCC_RTCCLKCmd(ENABLE);
|
||||
|
||||
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
|
||||
RTC_InitStruct.RTC_AsynchPrediv = 128;
|
||||
RTC_InitStruct.RTC_SynchPrediv = 256;
|
||||
|
||||
RTC_Init(&RTC_InitStruct);
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
|
||||
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
||||
RCC_RTCCLKCmd(ENABLE);
|
||||
|
||||
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
|
||||
RTC_InitStruct.RTC_AsynchPrediv = 128;
|
||||
RTC_InitStruct.RTC_SynchPrediv = 256;
|
||||
|
||||
RTC_Init(&RTC_InitStruct);
|
||||
|
||||
struct gtm utm;
|
||||
rtc_gettime(&utm);
|
||||
g_rtcTime = gmktime(&utm);
|
||||
}
|
||||
|
||||
+16
-16
@@ -35,25 +35,25 @@
|
||||
|
||||
void uartSendChar(uint8_t c)
|
||||
{
|
||||
USART_SendData(UART_DEBUG, c);
|
||||
|
||||
/* Wait for end of previous transfer */
|
||||
while (USART_GetFlagStatus(UART_DEBUG, USART_FLAG_TC) == RESET);
|
||||
USART_SendData(UART_DEBUG, c);
|
||||
|
||||
/* Wait for end of previous transfer */
|
||||
while (USART_GetFlagStatus(UART_DEBUG, USART_FLAG_TC) == RESET);
|
||||
}
|
||||
|
||||
|
||||
void uartInit(void)
|
||||
{
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART_DEBUG, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_RX, GPIO_AF_UART);
|
||||
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_TX, GPIO_AF_UART);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART_TX | GPIO_PIN_UART_RX;
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART_DEBUG, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_RX, GPIO_AF_UART);
|
||||
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_TX, GPIO_AF_UART);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART_TX | GPIO_PIN_UART_RX;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
@@ -67,7 +67,7 @@ void uartInit(void)
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Tx;
|
||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
|
||||
USART_Init(UART_DEBUG, &USART_InitStructure);
|
||||
USART_Cmd(UART_DEBUG, ENABLE);
|
||||
USART_Init(UART_DEBUG, &USART_InitStructure);
|
||||
USART_Cmd(UART_DEBUG, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UART_H
|
||||
#define __UART_H
|
||||
|
||||
#define DEBUG_UART_BAUDRATE 115200
|
||||
|
||||
void uartInit(void);
|
||||
void uartSendChar(uint8_t c);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user