mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-15 19:22:45 +03:00
[sam] PIO and PMC drivers adapted to enable SAM3U compilation, makefiles prepared for SAM3U-EK and Due
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
*/
|
||||
extern void PMC_EnablePeripheral( uint32_t dwId )
|
||||
{
|
||||
#if (defined _SAM3S_) || (defined _SAM3S8_) || (defined _SAM3XA_)
|
||||
assert( dwId < 35 ) ;
|
||||
|
||||
if ( dwId < 32 )
|
||||
@@ -56,6 +57,14 @@ extern void PMC_EnablePeripheral( uint32_t dwId )
|
||||
PMC->PMC_PCER1 = 1 << dwId ;
|
||||
}
|
||||
}
|
||||
#elif (defined _SAM3N_) || (defined _SAM3U_)
|
||||
if ( (PMC->PMC_PCSR & ((uint32_t)1 << dwId)) != ((uint32_t)1 << dwId) )
|
||||
{
|
||||
PMC->PMC_PCER = 1 << dwId ;
|
||||
}
|
||||
#else
|
||||
#error "The specified chip is not supported."
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,15 +77,12 @@ extern void PMC_EnablePeripheral( uint32_t dwId )
|
||||
*/
|
||||
extern void PMC_DisablePeripheral( uint32_t dwId )
|
||||
{
|
||||
#if (defined _SAM3S_) || (defined _SAM3S8_) || (defined _SAM3XA_)
|
||||
assert( dwId < 35 ) ;
|
||||
|
||||
if ( dwId < 32 )
|
||||
{
|
||||
if ( (PMC->PMC_PCSR0 & ((uint32_t)1 << dwId)) != ((uint32_t)1 << dwId) )
|
||||
{
|
||||
// TRACE_DEBUG("PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", dwId ) ;
|
||||
}
|
||||
else
|
||||
if ( (PMC->PMC_PCSR0 & ((uint32_t)1 << dwId)) == ((uint32_t)1 << dwId) )
|
||||
{
|
||||
PMC->PMC_PCDR0 = 1 << dwId ;
|
||||
}
|
||||
@@ -84,59 +90,69 @@ extern void PMC_DisablePeripheral( uint32_t dwId )
|
||||
else
|
||||
{
|
||||
dwId -= 32 ;
|
||||
if ( (PMC->PMC_PCSR1 & ((uint32_t)1 << dwId)) != ((uint32_t)1 << dwId) )
|
||||
{
|
||||
// TRACE_DEBUG( "PMC_DisablePeripheral: clock of peripheral" " %u is not enabled\n\r", dwId + 32 ) ;
|
||||
}
|
||||
else
|
||||
if ( (PMC->PMC_PCSR1 & ((uint32_t)1 << dwId)) == ((uint32_t)1 << dwId) )
|
||||
{
|
||||
PMC->PMC_PCDR1 = 1 << dwId ;
|
||||
}
|
||||
}
|
||||
#elif (defined _SAM3N_) || (defined _SAM3U_)
|
||||
if ( (PMC->PMC_PCSR & ((uint32_t)1 << dwId)) == ((uint32_t)1 << dwId) )
|
||||
{
|
||||
PMC->PMC_PCDR = 1 << dwId ;
|
||||
}
|
||||
#else
|
||||
#error "The specified chip is not supported."
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Enable all the periph clock via PMC.
|
||||
*/
|
||||
extern void PMC_EnableAllPeripherals( void )
|
||||
{
|
||||
PMC->PMC_PCER0 = MASK_STATUS0 ;
|
||||
while ( (PMC->PMC_PCSR0 & MASK_STATUS0) != MASK_STATUS0 ) ;
|
||||
|
||||
PMC->PMC_PCER1 = MASK_STATUS1 ;
|
||||
while ( (PMC->PMC_PCSR1 & MASK_STATUS1) != MASK_STATUS1 ) ;
|
||||
|
||||
// TRACE_DEBUG( "Enable all periph clocks\n\r" ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Disable all the periph clock via PMC.
|
||||
*/
|
||||
extern void PMC_DisableAllPeripherals( void )
|
||||
{
|
||||
PMC->PMC_PCDR0 = MASK_STATUS0 ;
|
||||
while ( (PMC->PMC_PCSR0 & MASK_STATUS0) != 0 ) ;
|
||||
|
||||
PMC->PMC_PCDR1 = MASK_STATUS1 ;
|
||||
while ( (PMC->PMC_PCSR1 & MASK_STATUS1) != 0 ) ;
|
||||
|
||||
// TRACE_DEBUG( "Disable all periph clocks\n\r" ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get Periph Status for the given peripheral ID.
|
||||
* \brief Get the status of the specified peripheral clock.
|
||||
*
|
||||
* \param id Peripheral ID (ID_xxx).
|
||||
* \note The ID must NOT be shifted (i.e. 1 << ID_xxx).
|
||||
*
|
||||
* \param dwId Peripheral ID (ID_xxx).
|
||||
*
|
||||
* \retval 0 Clock is active.
|
||||
* \retval 1 Clock is inactive.
|
||||
* \retval 2 Invalid parameter.
|
||||
*/
|
||||
extern uint32_t PMC_IsPeriphEnabled( uint32_t dwId )
|
||||
extern uint32_t PMC_IsPeripheralEnabled( uint32_t dwId )
|
||||
{
|
||||
#if (defined _SAM3S_) || (defined _SAM3S8_) || (defined _SAM3XA_)
|
||||
assert( dwId < 35 ) ;
|
||||
|
||||
if ( dwId < 32 )
|
||||
{
|
||||
return ( PMC->PMC_PCSR0 & (1 << dwId) ) ;
|
||||
if ( PMC->PMC_PCSR0 & (1 << dwId) )
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ( PMC->PMC_PCSR1 & (1 << (dwId - 32)) ) ;
|
||||
else
|
||||
{
|
||||
if ( PMC->PMC_PCSR1 & (1 << (dwId - 32)) )
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
#elif (defined _SAM3N_) || (defined _SAM3U_)
|
||||
if ( (PMC->PMC_PCSR & ((uint32_t)1 << dwId)) )
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1 ;
|
||||
}
|
||||
#else
|
||||
#error "The specified chip is not supported."
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user