mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-21 21:49:15 +01:00
[SC64][SW] Removed _oscillator running after time set_ check in the RTC, lowered I2C clock speed
This commit is contained in:
parent
b84213b3e4
commit
f7eb6a73b4
@ -460,7 +460,7 @@ static void hw_init_spi (void) {
|
||||
static void hw_init_i2c (void) {
|
||||
RCC->APBENR1 |= RCC_APBENR1_I2C1EN;
|
||||
|
||||
I2C1->TIMINGR = 0x00C12166UL;
|
||||
I2C1->TIMINGR = 0x80821B20UL;
|
||||
I2C1->CR1 |= (I2C_CR1_TCIE | I2C_CR1_STOPIE | I2C_CR1_RXIE | I2C_CR1_TXIE | I2C_CR1_PE);
|
||||
|
||||
hw_gpio_init(GPIO_ID_I2C_SCL, GPIO_ALT, GPIO_OD, GPIO_SPEED_VLOW, GPIO_PULL_NONE, GPIO_AF_6, 0);
|
||||
|
@ -93,18 +93,14 @@ static void rtc_sanitize_time (uint8_t *regs) {
|
||||
}
|
||||
}
|
||||
|
||||
static void rtc_wait_osc (bool running) {
|
||||
uint8_t rtcwkday;
|
||||
static void rtc_osc_stop (void) {
|
||||
uint8_t tmp = 0x00;
|
||||
|
||||
while (1) {
|
||||
rtc_read(RTC_ADDRESS_RTCWKDAY, &rtcwkday, 1);
|
||||
rtc_write(RTC_ADDRESS_RTCSEC, &tmp, 1);
|
||||
|
||||
if (running && (rtcwkday & RTC_RTCWKDAY_OSCRUN)) {
|
||||
return;
|
||||
} else if (!running && (!(rtcwkday & RTC_RTCWKDAY_OSCRUN))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
do {
|
||||
rtc_read(RTC_ADDRESS_RTCWKDAY, &tmp, 1);
|
||||
} while (tmp & RTC_RTCWKDAY_OSCRUN);
|
||||
}
|
||||
|
||||
static void rtc_read_time (void) {
|
||||
@ -130,11 +126,7 @@ static void rtc_read_time (void) {
|
||||
static void rtc_write_time (void) {
|
||||
uint8_t regs[7];
|
||||
|
||||
regs[0] = 0x00;
|
||||
|
||||
rtc_write(RTC_ADDRESS_RTCSEC, regs, 1);
|
||||
|
||||
rtc_wait_osc(false);
|
||||
rtc_osc_stop();
|
||||
|
||||
regs[0] = rtc_time.second;
|
||||
regs[1] = rtc_time.minute;
|
||||
@ -147,11 +139,10 @@ static void rtc_write_time (void) {
|
||||
rtc_sanitize_time(regs);
|
||||
|
||||
regs[0] |= RTC_RTCSEC_ST;
|
||||
regs[3] |= (RTC_RTCWKDAY_OSCRUN | RTC_RTCWKDAY_VBATEN);
|
||||
regs[3] |= RTC_RTCWKDAY_VBATEN;
|
||||
|
||||
rtc_write(RTC_ADDRESS_RTCSEC, regs, 7);
|
||||
|
||||
rtc_wait_osc(true);
|
||||
rtc_write(RTC_ADDRESS_RTCMIN, ®s[1], 6);
|
||||
rtc_write(RTC_ADDRESS_RTCSEC, ®s[0], 1);
|
||||
}
|
||||
|
||||
static void rtc_read_region (void) {
|
||||
@ -188,6 +179,7 @@ static void rtc_init (void) {
|
||||
if (uninitialized) {
|
||||
buffer[0] = 0;
|
||||
rtc_write(RTC_ADDRESS_SRAM_MAGIC, (uint8_t *) (magic), 4);
|
||||
rtc_write(RTC_ADDRESS_CONTROL, buffer, 1);
|
||||
rtc_write(RTC_ADDRESS_OSCTRIM, buffer, 1);
|
||||
rtc_write_time();
|
||||
rtc_write_region();
|
||||
|
Loading…
Reference in New Issue
Block a user