1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Added some utility functions in libsam for TC. (Neil H.)

This commit is contained in:
Cristian Maglie 2012-08-24 22:15:23 +02:00
parent a267a8a774
commit c3e44f363e
4 changed files with 82 additions and 27 deletions

View File

@ -68,6 +68,10 @@ extern void TC_Stop( Tc *pTc, uint32_t dwChannel ) ;
extern uint32_t TC_FindMckDivisor( uint32_t dwFreq, uint32_t dwMCk, uint32_t *dwDiv, uint32_t *dwTcClks, uint32_t dwBoardMCK ) ; extern uint32_t TC_FindMckDivisor( uint32_t dwFreq, uint32_t dwMCk, uint32_t *dwDiv, uint32_t *dwTcClks, uint32_t dwBoardMCK ) ;
extern uint32_t TC_ReadCV(Tc *p_tc, uint32_t ul_channel);
extern uint32_t TC_GetStatus(Tc *p_tc, uint32_t ul_channel);
extern void TC_SetRA(Tc *tc, uint32_t chan, uint32_t v) ; extern void TC_SetRA(Tc *tc, uint32_t chan, uint32_t v) ;
extern void TC_SetRB(Tc *tc, uint32_t chan, uint32_t v) ; extern void TC_SetRB(Tc *tc, uint32_t chan, uint32_t v) ;

View File

@ -173,14 +173,63 @@ extern uint32_t TC_FindMckDivisor( uint32_t dwFreq, uint32_t dwMCk, uint32_t *dw
return 1 ; return 1 ;
} }
/**
* \brief Read Timer Counter Counter Value on the selected TC & channel.
*
* \param p_tc Pointer to a TC instance.
* \param ul_channel Channel to configure.
*
* \return RC value.
*/
uint32_t TC_ReadCV(Tc *p_tc, uint32_t ul_channel){
return p_tc->TC_CHANNEL[ul_channel].TC_CV;
}
/**
* \brief Get current status on the selected channel.
*
* \param p_tc Pointer to a TC instance.
* \param ul_channel Channel to configure.
*
* \return The current TC status.
*/
uint32_t TC_GetStatus(Tc *p_tc, uint32_t ul_channel)
{
TcChannel *tc_channel;
tc_channel = p_tc->TC_CHANNEL + ul_channel;
return tc_channel->TC_SR;
}
/**
* \brief Set RA on the selected channel.
*
* \param tc Pointer to a TC instance.
* \param chan Channel to configure.
* \param v New value for RA.
*/
void TC_SetRA(Tc *tc, uint32_t chan, uint32_t v) { void TC_SetRA(Tc *tc, uint32_t chan, uint32_t v) {
tc->TC_CHANNEL[chan].TC_RA = v; tc->TC_CHANNEL[chan].TC_RA = v;
} }
/**
* \brief Set RB on the selected channel.
*
* \param tc Pointer to a TC instance.
* \param chan Channel to configure.
* \param v New value for RB.
*/
void TC_SetRB(Tc *tc, uint32_t chan, uint32_t v) { void TC_SetRB(Tc *tc, uint32_t chan, uint32_t v) {
tc->TC_CHANNEL[chan].TC_RB = v; tc->TC_CHANNEL[chan].TC_RB = v;
} }
/**
* \brief Set RC on the selected channel.
*
* \param tc Pointer to a TC instance.
* \param chan Channel to configure.
* \param v New value for RC.
*/
void TC_SetRC(Tc *tc, uint32_t chan, uint32_t v) { void TC_SetRC(Tc *tc, uint32_t chan, uint32_t v) {
tc->TC_CHANNEL[chan].TC_RC = v; tc->TC_CHANNEL[chan].TC_RC = v;
} }

View File

@ -72,7 +72,7 @@ pmc.o:
00000000 T pmc_switch_udpck_to_upllck 00000000 T pmc_switch_udpck_to_upllck
pwmc.o: pwmc.o:
00000000 r C.9.7272 00000000 r C.9.7280
00000000 t FindClockConfiguration 00000000 t FindClockConfiguration
00000000 T PWMC_ConfigureChannel 00000000 T PWMC_ConfigureChannel
00000000 T PWMC_ConfigureChannelExt 00000000 T PWMC_ConfigureChannelExt
@ -100,14 +100,14 @@ pwmc.o:
00000000 T PWMC_SetSyncChannelUpdateUnlock 00000000 T PWMC_SetSyncChannelUpdateUnlock
00000000 T PWMC_WriteBuffer 00000000 T PWMC_WriteBuffer
U __assert_func U __assert_func
00000000 r __func__.5968 00000000 r __func__.5974
00000000 r __func__.5979 00000000 r __func__.5985
00000000 r __func__.5994 00000000 r __func__.6000
00000000 r __func__.6005 00000000 r __func__.6011
00000000 r __func__.6016 00000000 r __func__.6022
00000000 r __func__.6023 00000000 r __func__.6029
00000000 r __func__.6107
00000000 r __func__.6113 00000000 r __func__.6113
00000000 r __func__.6119
rtc.o: rtc.o:
00000000 T RTC_ClearSCCR 00000000 T RTC_ClearSCCR
@ -123,9 +123,9 @@ rtc.o:
00000000 T RTC_SetTime 00000000 T RTC_SetTime
00000000 T RTC_SetTimeAlarm 00000000 T RTC_SetTimeAlarm
U __assert_func U __assert_func
00000000 r __func__.5965 00000000 r __func__.5971
00000000 r __func__.5974 00000000 r __func__.5980
00000000 r __func__.5979 00000000 r __func__.5985
rtt.o: rtt.o:
00000000 T RTT_EnableIT 00000000 T RTT_EnableIT
@ -134,8 +134,8 @@ rtt.o:
00000000 T RTT_SetAlarm 00000000 T RTT_SetAlarm
00000000 T RTT_SetPrescaler 00000000 T RTT_SetPrescaler
U __assert_func U __assert_func
00000000 r __func__.5972 00000000 r __func__.5978
00000000 r __func__.5980 00000000 r __func__.5986
spi.o: spi.o:
00000000 T SPI_Configure 00000000 T SPI_Configure
@ -153,15 +153,17 @@ spi.o:
tc.o: tc.o:
00000000 T TC_Configure 00000000 T TC_Configure
00000000 T TC_FindMckDivisor 00000000 T TC_FindMckDivisor
00000000 T TC_GetStatus
00000000 T TC_ReadCV
00000000 T TC_SetRA 00000000 T TC_SetRA
00000000 T TC_SetRB 00000000 T TC_SetRB
00000000 T TC_SetRC 00000000 T TC_SetRC
00000000 T TC_Start 00000000 T TC_Start
00000000 T TC_Stop 00000000 T TC_Stop
U __assert_func U __assert_func
00000000 r __func__.5967
00000000 r __func__.5973 00000000 r __func__.5973
00000000 r __func__.5979 00000000 r __func__.5979
00000000 r __func__.5985
timetick.o: timetick.o:
00000000 T GetTickCount 00000000 T GetTickCount
@ -188,18 +190,18 @@ twi.o:
00000000 T TWI_TransferComplete 00000000 T TWI_TransferComplete
00000000 T TWI_WriteByte 00000000 T TWI_WriteByte
U __assert_func U __assert_func
00000000 r __func__.6340 00000000 r __func__.6346
00000000 r __func__.6355 00000000 r __func__.6361
00000000 r __func__.6359 00000000 r __func__.6365
00000000 r __func__.6366 00000000 r __func__.6372
00000000 r __func__.6370 00000000 r __func__.6376
00000000 r __func__.6375 00000000 r __func__.6381
00000000 r __func__.6383 00000000 r __func__.6389
00000000 r __func__.6397 00000000 r __func__.6403
00000000 r __func__.6402 00000000 r __func__.6408
00000000 r __func__.6406 00000000 r __func__.6412
00000000 r __func__.6411 00000000 r __func__.6417
00000000 r __func__.6415 00000000 r __func__.6421
usart.o: usart.o:
00000000 T USART_Configure 00000000 T USART_Configure
@ -218,7 +220,7 @@ usart.o:
00000000 T USART_Write 00000000 T USART_Write
00000000 T USART_WriteBuffer 00000000 T USART_WriteBuffer
U __assert_func U __assert_func
00000000 r __func__.6261 00000000 r __func__.6267
wdt.o: wdt.o:
00000000 T WDT_Disable 00000000 T WDT_Disable